-
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
Add parser support for PEP 696 #11099
Comments
Thank you for notifying us about the new syntax!
Yes, of course! Although the parser crate ( I'll need to go through the PEP to list the work items needed to complete this, but for reference, there's the PEP 701 issue and PEP 695 issue. At a high level, this will impact all of the major areas: the AST, parser, linter, and formatter. If you're solely interested in updating the AST and parser, that's perfectly fine; either I or someone else from the team can handle implementing the changes in the linter and formatter. |
Thanks! I'll take a look myself first and let you know if I run into any issues. I expect the PEP 695 issue will provide a good reference as mechanically the new syntax is very similar to the bound syntax in PEP 695. |
#11120 implements support in all the places I could find in the Ruff codebase. Rust's ADTs were very nice here; the compiler basically told me almost all the places I had to update. There's a test failure that I'll look into soon. At runtime this sort of thing is an error:
Since Ruff doesn't detect a few similar cases in the existing syntax (#11118, #11119), I left these error checks out of the PEP 696 support too. It might make sense to add a new lint rule checking for these and similar issues, but that can wait for a different PR. |
We do detect this specific case for function parameters. For reference: ruff/crates/ruff_python_parser/src/parser/statement.rs Lines 3055 to 3070 in f5c7a62
|
Ruff's parser does not support the new syntax introduced by PEP 696:
I noticed because I'm adding this syntax to CPython and Ruff started failing in CI :).
I saw that you recently switched to a handwritten parser. I'm interested in taking a look at that parser, so I'd like to try to implement this myself.
The text was updated successfully, but these errors were encountered: