Skip to content

Simplify quote annotator logic for list expression#14425

Merged
dhruvmanila merged 1 commit into
mainfrom
dhruv/simplify-quote-annotation
Nov 18, 2024
Merged

Simplify quote annotator logic for list expression#14425
dhruvmanila merged 1 commit into
mainfrom
dhruv/simplify-quote-annotation

Conversation

@dhruvmanila

Copy link
Copy Markdown
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

dhruvmanila commented Nov 18, 2024

Copy link
Copy Markdown
Member Author

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
@dhruvmanila dhruvmanila deleted the dhruv/simplify-quote-annotation branch November 18, 2024 07:03
@github-actions

Copy link
Copy Markdown
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