Fix trailing kwargs end of line comment after slash (#10297) · astral-sh/ruff@965adbe (original) (raw)
File tree
3 files changed
lines changed
- crates/ruff_python_formatter
- resources/test/fixtures/ruff/statement
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -278,6 +278,13 @@ def f42( | ||
278 | 278 | ): |
279 | 279 | pass |
280 | 280 | |
281 | +# Regression test for https://github.com/astral-sh/ruff/issues/10281 | |
282 | +def f43( | |
283 | +__bar: str, | |
284 | +/, | |
285 | +**specifiers: typing.Any, # noqa: ANN401 | |
286 | +) -> int: | |
287 | +return len(specifiers) | |
281 | 288 | |
282 | 289 | # Check trailing commas are permitted in funcdef argument list. |
283 | 290 | def f(a, ): pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -450,13 +450,15 @@ pub(crate) fn find_parameter_separators( | ||
450 | 450 | // * `f(a, /, b)` |
451 | 451 | // * `f(a, /, *b)` |
452 | 452 | // * `f(a, /, *, b)` |
453 | +// * `f(a, /, *, **b)` | |
453 | 454 | // * `f(a, /)` |
454 | 455 | let slash_following_start = parameters |
455 | 456 | .args |
456 | 457 | .first() |
457 | 458 | .map(Ranged::start) |
458 | 459 | .or(parameters.vararg.as_ref().map(|first |
459 | 460 | .or(star.as_ref().map(|star |
461 | +.or(parameters.kwarg.as_deref().map(Ranged::start)) | |
460 | 462 | .unwrap_or(parameters.end()); |
461 | 463 | let slash = slash.map(|(preceding_end, slash) |
462 | 464 | preceding_end, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -284,6 +284,13 @@ def f42( | ||
284 | 284 | ): |
285 | 285 | pass |
286 | 286 | |
287 | +# Regression test for https://github.com/astral-sh/ruff/issues/10281 | |
288 | +def f43( | |
289 | +__bar: str, | |
290 | + /, | |
291 | + **specifiers: typing.Any, # noqa: ANN401 | |
292 | +) -> int: | |
293 | + return len(specifiers) | |
287 | 294 | |
288 | 295 | # Check trailing commas are permitted in funcdef argument list. |
289 | 296 | def f(a, ): pass |
@@ -760,6 +767,15 @@ def f42( | ||
760 | 767 | pass |
761 | 768 | |
762 | 769 | |
770 | +# Regression test for https://github.com/astral-sh/ruff/issues/10281 | |
771 | +def f43( | |
772 | +__bar: str, | |
773 | + /, | |
774 | + **specifiers: typing.Any, # noqa: ANN401 | |
775 | +) -> int: | |
776 | + return len(specifiers) | |
777 | + | |
778 | + | |
763 | 779 | # Check trailing commas are permitted in funcdef argument list. |
764 | 780 | def f( |
765 | 781 | a, |
@@ -999,6 +1015,3 @@ def function_with_one_argument_and_a_keyword_separator( | ||
999 | 1015 | ) -> ReallyReallyReallyReallyReallyReallyReallyReallyLongName: |
1000 | 1016 | pass |
1001 | 1017 | ``` |
1002 | - | |
1003 | - | |
1004 | - |