You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from __future__ importannotationsfromtypingimportTYPE_CHECKING, Finalfromcollections.abcimportMappingifTYPE_CHECKING:
fromcollections.abcimportSequenceConst: Final[Mapping[str, Sequence]] = {}
and gets reformatted as
from __future__ importannotationsfromtypingimportTYPE_CHECKING, FinalifTYPE_CHECKING:
fromcollections.abcimportMappingfromcollections.abcimportSequenceConst: Final[Mapping[str, Sequence]] = {}
I think it's because the TYPE_CHECKING block does not exist yet that it's like that. However, if the block is empty and only typing imports exist, it also fails:
from __future__ importannotationsfromtypingimportTYPE_CHECKING, FinalifTYPE_CHECKING:
passConst: Final[float] =1
The text was updated successfully, but these errors were encountered:
picnixz
changed the title
[Linter panic] Fixing TCH003 when no TYPE_CHECKING block exists fails and empty exempt-modules
[Linter panic] Fixing TCH003 fails when no TYPE_CHECKING block exists and exempt-modules is empty
Dec 19, 2023
## Summary
If you remove `typing` from `exempt-modules`, we tend to panic, since we
try to add `TYPE_CHECKING` to `from typing import ...` statements while
concurrently attempting to remove other members from that import. This
PR adds special-casing for typing imports to avoid such panics.
Closes#5331Closes#9196.
Closes#9197.
I'm not sure that it's the place to ask since this bug appears to be caused by
[tool.ruff.lint.flake8-type-checking]
. Anyway, with the configurationinvoking
on
fails with
But the following succeeds:
and gets reformatted as
I think it's because the
TYPE_CHECKING
block does not exist yet that it's like that. However, if the block is empty and onlytyping
imports exist, it also fails:Now, if I change
to
it works as intended.
Environment
The text was updated successfully, but these errors were encountered: