Skip to content

Remove duplicate TYPE_CHECKING imports#20878

Merged
hauntsaninja merged 1 commit intopython:masterfrom
ntBre:brent/type-visitor
Feb 24, 2026
Merged

Remove duplicate TYPE_CHECKING imports#20878
hauntsaninja merged 1 commit intopython:masterfrom
ntBre:brent/type-visitor

Conversation

@ntBre
Copy link
Contributor

@ntBre ntBre commented Feb 23, 2026

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:

python runtests.py

I also ran:

tox run -e py310

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.

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
```
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this should be good :-)

@ntBre ntBre marked this pull request as ready for review February 23, 2026 23:30
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja merged commit a9fc81a into python:master Feb 24, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants