tweag/FawltyDeps
Imports protected by TYPE_CHECKING are treated as mandatory
Aperta
#390 aperta il 3 nov 2023
P3good first issueparsing-imports
Metriche repository
- Star
- (288 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Describe the bug
Code which is protected by TYPE_CHECKING is listed as a required import. I'm not sure if to class this as a bug or a feature request but this template fits better.
For example:
from typing import TYPE_CHECKING
import foo
if TYPE_CHECKING:
import bar
To Reproduce
bash-5.2$ echo $'from typing import TYPE_CHECKING\nimport foo\nif TYPE_CHECKING:\n import bar' | fawltydeps --list-imports --code - --detailed
<stdin>:2: foo
<stdin>:4: bar
Expected behavior
Import protected by TYPE_CHECKING can be ignored.
Environment
- Version of the code: 0.13.2
Additional context