-
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
[flake8-type-checking
] Consider type expressions in list for quoting annotations
#14371
Conversation
Notice that the snapshot I updated was for a test that already existed - the fixture contains almost exactly the example from the linked issue. It seems to me like the previous behavior was incorrect and the new behavior is correct - but maybe I'm missing something? |
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
W293 | 1 | 1 | 0 | 0 | 0 |
W292 | 1 | 1 | 0 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
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.
This looks correct to me. I don't know anything about helpers.rs
but you're doing the same as is done in other places, so it must be correct 😆
…ons in quotes (astral-sh#14371) This PR adds corrected handling of list expressions to the `Visitor` implementation of `QuotedAnnotator` in `flake8_type_checking::helpers`. Closes astral-sh#14368
flake8-type-checking
] Fix helper function which surrounds annotations in quotesflake8-type-checking
] Consider type expressions in list for quoting annotations
## 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](https://typing.readthedocs.io/en/latest/spec/annotations.html#grammar-token-expression-grammar-annotation_expression), 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`
This PR adds corrected handling of list expressions to the
Visitor
implementation ofQuotedAnnotator
inflake8_type_checking::helpers
.Closes #14368