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

Simplify quote annotator logic for list expression #14425

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

dhruvmanila
Copy link
Member

Summary

Follow-up to #14371, this PR simplifies the visitor logic for list expressions to remove the state management. We just need to make sure that we visit the nested expressions using the QuoteAnnotator and not the Generator. This is similar to what's being done for binary expressions.

As per the grammar, list expressions can be present which can contain other type expressions (Callable):

       | <Callable> '[' <Concatenate> '[' (type_expression ',')+
                    (name | '...') ']' ',' type_expression ']'
             (where name must be a valid in-scope ParamSpec)
       | <Callable> '[' '[' maybe_unpacked (',' maybe_unpacked)*
                    ']' ',' type_expression ']'

Test Plan

cargo insta test

@dhruvmanila dhruvmanila added the internal An internal refactor or improvement label Nov 18, 2024
@dhruvmanila
Copy link
Member Author

dhruvmanila commented Nov 18, 2024

I think even starred expressions should be considered here:

unpacked              ::=  '*' unpackable
                           | <Unpack> '[' unpackable ']'
unpackable            ::=  tuple_type_expression`
                           | name
                                 (where name must refer to an in-scope TypeVarTuple)
tuple_type_expression ::=  <tuple> '[' '(' ')' ']'
                                (representing an empty tuple)
                           | <tuple> '[' type_expression ',' '...' ']'
                                 (representing an arbitrary-length tuple)
                           | <tuple> '[' maybe_unpacked (',' maybe_unpacked)* ']'

@dhruvmanila dhruvmanila merged commit 38a385f into main Nov 18, 2024
20 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/simplify-quote-annotation branch November 18, 2024 07:03
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants