-
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
] Support auto-quoting when annotations contain quotes
#11811
Changes from 5 commits
65a38e9
c8df851
d97e2bd
8ca1f5c
29e0d4a
1b58828
14f51e3
e8c0f90
c6ef3db
75f4407
3a253f6
bf363e2
f27ae89
2b58cbb
fbf0bb1
5079a8c
f7e19b4
26081a6
5c4b4df
d4602a2
114edd0
ff973d4
2c10896
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a large snapshot diff because one of the test case was removed which had |
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.
I think I know why the test is failing within the current
MAX_ITERATIONS
value. All of the different test cases are within the same function here so when some of them tries to add theif TYPE_CHECKING
block along with theTYPE_CHECKING
import, the edits collide and thus it won't be applied which will then require another iteration. We should split the test cases, grouping them based on similarity, in similar way as done in the top half of the file.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.
You are right. I think I can fix that easily. There's just another problem I encountered. Aside from the new tests I've written the old ones also have this problem that each time the type annotation is changed a new import is added and the duplicate imports I think are removed in the end. So now the file fails again.
It can be reproduced by just duplicating one of the functions multiple times in master:
My guess is that two rules are conflicting here. One is moving the import to type checking block but since now that import is in type checking block another function later in the quote.py is using that import and it is resolved when the symbol is looked up here
I'm not sure if I'm right because the import should be resolved to the import inside the function itself. It's my guess. I will investigate this later after resolving other issues.
For now I'm going to create a new file that will avoid this issue. Moving my new test cases to a file works fine.