-
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
Fix incorrect Parameter
range for *args
and **kwargs
#10283
Fix incorrect Parameter
range for *args
and **kwargs
#10283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the diff supposed to be that big? I used the same version of lalrpop
(0.20.0) to update this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, lalrpop loves to generate large diffs :(
Changing the ranges drips over the formatter. There are multiple places where the formatter goes back to introspecting the source to identify the comment placement and I fear that the code has now been written in a way that assumes the incorrect I've been able to identify a problematic example: (
lambda # comment 1
* # comment 2
x: # comment 3
x
) But I haven't yet been successful to narrow it down where the range handling is happening. I suspect that it is related to #10281 (CC: @dhruvmanila) but haven't been able to confirm it yet. I suspect that the relevant code is ruff/crates/ruff_python_formatter/src/other/parameters.rs Lines 357 to 644 in 0293908
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix for the formatter.
Looks good to me. That's a non-trivial parser change. Well done!
Would you mind rebasing and regenerating the parser (after rebase)?
I can rebase, regen, and merge this later. |
f54010c
to
1aeb5c1
Compare
Thanks for the formatter fix! I rebased and regenerated the parser |
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
ANN003 | 4590 | 2295 | 2295 | 0 | 0 |
ANN002 | 1846 | 923 | 923 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+3218 -3218 violations, +0 -0 fixes in 2 projects; 41 projects unchanged)
apache/airflow (+2275 -2275 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ airflow/api/auth/backend/default.py:38:19: ANN002 Missing type annotation for `*args` - airflow/api/auth/backend/default.py:38:20: ANN002 Missing type annotation for `*args` + airflow/api/auth/backend/default.py:38:26: ANN003 Missing type annotation for `**kwargs` - airflow/api/auth/backend/default.py:38:28: ANN003 Missing type annotation for `**kwargs` + airflow/api/auth/backend/deny_all.py:40:19: ANN002 Missing type annotation for `*args` - airflow/api/auth/backend/deny_all.py:40:20: ANN002 Missing type annotation for `*args` + airflow/api/auth/backend/deny_all.py:40:26: ANN003 Missing type annotation for `**kwargs` - airflow/api/auth/backend/deny_all.py:40:28: ANN003 Missing type annotation for `**kwargs` + airflow/api/auth/backend/kerberos_auth.py:153:19: ANN002 Missing type annotation for `*args` - airflow/api/auth/backend/kerberos_auth.py:153:20: ANN002 Missing type annotation for `*args` + airflow/api/auth/backend/kerberos_auth.py:153:26: ANN003 Missing type annotation for `**kwargs` - airflow/api/auth/backend/kerberos_auth.py:153:28: ANN003 Missing type annotation for `**kwargs` + airflow/api/auth/backend/session.py:41:19: ANN002 Missing type annotation for `*args` - airflow/api/auth/backend/session.py:41:20: ANN002 Missing type annotation for `*args` + airflow/api/auth/backend/session.py:41:26: ANN003 Missing type annotation for `**kwargs` - airflow/api/auth/backend/session.py:41:28: ANN003 Missing type annotation for `**kwargs` + airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:102:14: ANN003 Missing type annotation for `**kwargs` - airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:102:16: ANN003 Missing type annotation for `**kwargs` + airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:108:15: ANN003 Missing type annotation for `**kwargs` - airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:108:17: ANN003 Missing type annotation for `**kwargs` + airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:114:15: ANN003 Missing type annotation for `**kwargs` - airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:114:17: ANN003 Missing type annotation for `**kwargs` + airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:121:16: ANN003 Missing type annotation for `**kwargs` - airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:121:18: ANN003 Missing type annotation for `**kwargs` + airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:128:17: ANN003 Missing type annotation for `**kwargs` - airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:128:19: ANN003 Missing type annotation for `**kwargs` ... 3595 additional changes omitted for rule ANN003 + airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:39:15: ANN002 Missing type annotation for `*args` - airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:39:16: ANN002 Missing type annotation for `*args` + airflow/api_connexion/parameters.py:100:30: ANN002 Missing type annotation for `*args` - airflow/api_connexion/parameters.py:100:31: ANN002 Missing type annotation for `*args` + airflow/api_connexion/security.py:118:23: ANN002 Missing type annotation for `*args` - airflow/api_connexion/security.py:118:24: ANN002 Missing type annotation for `*args` + airflow/api_connexion/security.py:163:23: ANN002 Missing type annotation for `*args` - airflow/api_connexion/security.py:163:24: ANN002 Missing type annotation for `*args` + airflow/api_connexion/security.py:180:23: ANN002 Missing type annotation for `*args` ... 4515 additional changes omitted for project
bokeh/bokeh (+943 -943 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ examples/basic/data/ajax_source.py:34:26: ANN002 Missing type annotation for `*args` - examples/basic/data/ajax_source.py:34:27: ANN002 Missing type annotation for `*args` + examples/basic/data/ajax_source.py:34:33: ANN003 Missing type annotation for `**kwargs` - examples/basic/data/ajax_source.py:34:35: ANN003 Missing type annotation for `**kwargs` + examples/basic/data/server_sent_events_source.py:36:26: ANN002 Missing type annotation for `*args` - examples/basic/data/server_sent_events_source.py:36:27: ANN002 Missing type annotation for `*args` + examples/basic/data/server_sent_events_source.py:36:33: ANN003 Missing type annotation for `**kwargs` - examples/basic/data/server_sent_events_source.py:36:35: ANN003 Missing type annotation for `**kwargs` + examples/models/graphs.py:22:78: ANN003 Missing type annotation for `**kwargs` - examples/models/graphs.py:22:80: ANN003 Missing type annotation for `**kwargs` + src/bokeh/core/property/struct.py:58:24: ANN003 Missing type annotation for `**fields` - src/bokeh/core/property/struct.py:58:26: ANN003 Missing type annotation for `**fields` ... 971 additional changes omitted for rule ANN003 + src/bokeh/core/property/validation.py:93:14: ANN002 Missing type annotation for `*args` - src/bokeh/core/property/validation.py:93:15: ANN002 Missing type annotation for `*args` ... 1872 additional changes omitted for project
Changes by rule (2 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
ANN003 | 4590 | 2295 | 2295 | 0 | 0 |
ANN002 | 1846 | 923 | 923 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
…#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`.
Summary
Fix #10282
This PR updates the Python grammar to include the
*
character in*args
**kwargs
in the range of theParameter
The invalid syntax
def f(*, **kwargs): ...
is also now correctly reported.Test Plan
Test cases were added to
function.rs
.