Remove duplicate TYPE_CHECKING imports#20878
Merged
hauntsaninja merged 1 commit intopython:masterfrom Feb 24, 2026
Merged
Conversation
Summary -- While reviewing astral-sh/ruff#22560, which expands our `redefined-while-unused` rule to catch re-imports in `TYPE_CHECKING` blocks, we noticed a new diagnostic on this code. When I checked the blame and noticed that the comment was 8 years old, I thought it might be worth trying to remove the import. I'm very happy to close this if I'm missing something, but the tests seem to be passing locally, so I figured I'd open a PR! Test Plan -- I set up my environment based on the contributing guide and then ran: ```shell python runtests.py ```
hauntsaninja
approved these changes
Feb 23, 2026
Collaborator
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks, this should be good :-)
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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.
Summary
While reviewing astral-sh/ruff#22560, which expands our
redefined-while-unusedrule to catch re-imports inTYPE_CHECKINGblocks, we noticed a new diagnostic on this code. When I checked the blame and noticed that the comment was 8 years old, I thought it might be worth trying to remove the import. I'm very happy to close this if I'm missing something, but the tests seem to be passing locally, so I figured I'd open a PR!Test Plan
I set up my environment based on the contributing guide and then ran:
I also ran:
to see if 3.14 was special. However, this is failing for me even on master with what looks like an error from the C compiler, so I figured I'd open the PR anyway and check in CI, assuming that's just a problem with my local environment.