-
Notifications
You must be signed in to change notification settings - Fork 944
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 parenthesized
flag to ExprTuple
and ExprGenerator
#9614
Conversation
crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs
Outdated
Show resolved
Hide resolved
55c761c
to
1e449cd
Compare
|
If we track this for tuples, should we also track it for generators, where it's also optional? |
I def support this. I think I tried to pitch it at one point but there wasn't enough interest 😂 |
1e449cd
to
07a842f
Compare
is_parenthesized
flag to ExprTuple
is_parenthesized
flag to ExprTuple
and ExprGenerator
is_parenthesized
flag to ExprTuple
and ExprGenerator
parenthesized
flag to ExprTuple
and ExprGenerator
cd91a92
to
7766548
Compare
Summary
This PR adds an
parenthesized
prop toExprTuple
andExprGenerator
that expose if the tuple/genrator is parenthesized in the source.The information is useful during linting and formatting, and dedecting if a tuple is parenthesized is somewhat involved.
Should this information be present in the AST: IMO, properties that are needed more than once are worth tracking in the AST, even if they don't have any semantical meaning.
It also simplifies implementing the new parser where it otherwise would need to be necessary to track the information separately.
Test Plan
I added new tests and reviewed the snapshot changes