Skip to content

Commit 4957bea

Browse files
committed
Further compatibility fix for Python 3.12
1 parent 3d51013 commit 4957bea

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

astatine/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ def is_type_checking(node: ast.AST) -> bool:
113113
if isinstance(node, ast.If):
114114
node = node.test
115115

116-
if isinstance(node, ast.NameConstant) and node.value is False:
117-
return True
118-
elif isinstance(node, ast.Name) and node.id == "TYPE_CHECKING":
116+
if sys.version_info < (3, 12): # pragma: no cover (py312+)
117+
if isinstance(node, ast.NameConstant) and node.value is False:
118+
return True
119+
else: # pragma: no cover (<py312)
120+
if isinstance(node, ast.Constant) and node.value is False:
121+
return True
122+
123+
if isinstance(node, ast.Name) and node.id == "TYPE_CHECKING":
119124
return True
120125
elif isinstance(node, ast.Attribute) and node.attr == "TYPE_CHECKING":
121126
return True

0 commit comments

Comments
 (0)