[flake8-type-checking] Consider type expressions in list for quoting annotations#14371
Merged
charliermarsh merged 3 commits intoastral-sh:mainfrom Nov 16, 2024
Merged
[flake8-type-checking] Consider type expressions in list for quoting annotations#14371charliermarsh merged 3 commits intoastral-sh:mainfrom
flake8-type-checking] Consider type expressions in list for quoting annotations#14371charliermarsh merged 3 commits intoastral-sh:mainfrom
Conversation
Collaborator
Author
|
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? |
Contributor
|
| 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.
MichaReiser
approved these changes
Nov 16, 2024
Member
MichaReiser
left a comment
There was a problem hiding this comment.
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 😆
dylwil3
added a commit
to dylwil3/ruff
that referenced
this pull request
Nov 17, 2024
…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
dhruvmanila
added a commit
that referenced
this pull request
Nov 18, 2024
## 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds corrected handling of list expressions to the
Visitorimplementation ofQuotedAnnotatorinflake8_type_checking::helpers.Closes #14368