-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Parameter
range is incorrect for *args
and **kwargs
#10282
Labels
internal
An internal refactor or improvement
Comments
I generally agree, since |
nkxxll
pushed a commit
to nkxxll/ruff
that referenced
this issue
Mar 10, 2024
…#10283) ## Summary Fix astral-sh#10282 This PR updates the Python grammar to include the `*` character in `*args` `**kwargs` in the range of the `Parameter` ``` def f(*args, **kwargs): pass # ~~~~ ~~~~~~ <-- range before the PR # ^^^^^ ^^^^^^^^ <-- range after ``` The invalid syntax `def f(*, **kwargs): ...` is also now correctly reported. ## Test Plan Test cases were added to `function.rs`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm working on a fix for the
flake8-unused-arguments
(ARG) rules that would delete them.While working on this, I noticed that the
*args
and**kwargs
Parameter.range
does not include the*
.I think that
Parameter.range
should include*
or**
, leavingParameter.name.range
for the actual name range if needed.See the currently generated AST
ruff/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap
Lines 58 to 67 in 7b4a73d
Here I would expect the
Parameter
range to be 1 longer than theIdentifier
range.ruff/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap
Lines 124 to 134 in 7b4a73d
And here I would expect the
Parameter
range to be 2 longer than theIdentifier
range.If this is indeed considered a bug, I have a PR ready to fix it.
The text was updated successfully, but these errors were encountered: