tweag/FawltyDeps

Imports protected by TYPE_CHECKING are treated as mandatory

オープン

#390 opened on 2023/11/03

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)Python (18 件のフォーク)auto 404
P3good first issueparsing-imports

Repository metrics

Stars
 (288 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

コントリビューターガイド