Description
If you manually set TYPE_CHECKING to False and use it with __future__.annotations, ruff will raise TC003/TC002/TC001 falsepositives on the imports in your TYPE_CHECKING block as it seems to only check for typing.TYPE_CHECKING.
Command: ruff check test.py --isolated --fix --select TC
Version: 0.9.2
Keywords: "TYPE_CHECKING", "TC003", "future.annotations", "TC002", "TC001"
Sample Code
test.py
from __future__ import annotations
TYPE_CHECKING = False
if TYPE_CHECKING:
from types import TracebackType
def foo(tb: TracebackType):...
$ ruff check test.py --isolated --fix --select TC
test.py:5:23: TC003 Move standard library import `types.TracebackType` into a type-checking block
|
3 | TYPE_CHECKING = False
4 | if TYPE_CHECKING:
5 | from types import TracebackType
| ^^^^^^^^^^^^^ TC003
6 |
7 | def foo(tb: TracebackType):...
|
= help: Move into type-checking block
Found 1 error.