-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
TCH003 seems to incorrectly trigger when re-exporting a module in __all__ if using from __future__ import annotations.
Minimal reproducible code:
# foo.py
from __future__ import annotations
from logging import getLogger
__all__ = ("getLogger",)
def foo() -> None:
pass$ pipx run ruff==0.0.281 foo.py
foo.py:3:21: TCH003 [*] Move standard library import `logging.getLogger` into a type-checking block
Found 1 error.
[*] 1 potentially fixable with the --fix option.In the example above, we import getLogger from logging to re-export it in __all__, and TCH003 will get triggered, although it should not.
Note that this does not trigger when removing from __future__ import annotations. It also doesn't trigger in version 0.0.280, so this seems to be related to a change in 0.0.281.
What's even weirder is that the violation will also not trigger in the example if we remove the return type (-> None) from the function.
Command used:
pipx run ruff==0.0.281 foo.pyMinimal Ruff settings to reproduce:
[tool.ruff]
select = [
# flake8-type-checking
"TCH",
]Ruff version:
ruff 0.0.281
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working