Skip to content

Commit

Permalink
Further compatibility fix for Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Aug 15, 2023
1 parent 3d51013 commit 4957bea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions astatine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ def is_type_checking(node: ast.AST) -> bool:
if isinstance(node, ast.If):
node = node.test

if isinstance(node, ast.NameConstant) and node.value is False:
return True
elif isinstance(node, ast.Name) and node.id == "TYPE_CHECKING":
if sys.version_info < (3, 12): # pragma: no cover (py312+)
if isinstance(node, ast.NameConstant) and node.value is False:
return True
else: # pragma: no cover (<py312)
if isinstance(node, ast.Constant) and node.value is False:
return True

if isinstance(node, ast.Name) and node.id == "TYPE_CHECKING":
return True
elif isinstance(node, ast.Attribute) and node.attr == "TYPE_CHECKING":
return True
Expand Down

0 comments on commit 4957bea

Please sign in to comment.