Skip to content

Commit

Permalink
fix TYPE_CHECKING condition checking
Browse files Browse the repository at this point in the history
  • Loading branch information
zhPavel committed Aug 29, 2024
1 parent 6b38a8c commit 26c8823
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/adaptix/_internal/type_tools/type_evaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
def make_fragments_collector(*, typing_modules: Sequence[str]) -> Callable[[ast.Module], list[ast.stmt]]:
def check_condition(expr: ast.expr) -> bool:
# searches for `TYPE_CHECKING`
if isinstance(expr, ast.Name) and isinstance(expr.ctx, ast.Load):
if (
isinstance(expr, ast.Name)
and isinstance(expr.ctx, ast.Load)
and expr.id == "TYPE_CHECKING"
):
return True

# searches for `typing.TYPE_CHECKING`
Expand Down

0 comments on commit 26c8823

Please sign in to comment.