Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trailing kwargs end of line comment after slash #10297

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ def f42(
):
pass

# Regression test for https://github.com/astral-sh/ruff/issues/10281
def f43(
__bar: str,
/,
**specifiers: typing.Any, # noqa: ANN401
) -> int:
return len(specifiers)

# Check trailing commas are permitted in funcdef argument list.
def f(a, ): pass
Expand Down
2 changes: 2 additions & 0 deletions crates/ruff_python_formatter/src/other/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,15 @@ pub(crate) fn find_parameter_separators(
// * `f(a, /, b)`
// * `f(a, /, *b)`
// * `f(a, /, *, b)`
// * `f(a, /, *, **b)`
// * `f(a, /)`
let slash_following_start = parameters
.args
.first()
.map(Ranged::start)
.or(parameters.vararg.as_ref().map(|first| first.start()))
.or(star.as_ref().map(|star| star.separator.start()))
.or(parameters.kwarg.as_deref().map(Ranged::start))
MichaReiser marked this conversation as resolved.
Show resolved Hide resolved
.unwrap_or(parameters.end());
let slash = slash.map(|(preceding_end, slash)| ParameterSeparator {
preceding_end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ def f42(
):
pass

# Regression test for https://github.com/astral-sh/ruff/issues/10281
def f43(
__bar: str,
/,
**specifiers: typing.Any, # noqa: ANN401
) -> int:
return len(specifiers)

# Check trailing commas are permitted in funcdef argument list.
def f(a, ): pass
Expand Down Expand Up @@ -760,6 +767,15 @@ def f42(
pass


# Regression test for https://github.com/astral-sh/ruff/issues/10281
def f43(
__bar: str,
/,
**specifiers: typing.Any, # noqa: ANN401
) -> int:
return len(specifiers)


# Check trailing commas are permitted in funcdef argument list.
def f(
a,
Expand Down Expand Up @@ -999,6 +1015,3 @@ def function_with_one_argument_and_a_keyword_separator(
) -> ReallyReallyReallyReallyReallyReallyReallyReallyLongName:
pass
```



Loading