Skip to content

Commit

Permalink
refactor: we no longer care what kind of constant the compile-time co…
Browse files Browse the repository at this point in the history
…nstants are
  • Loading branch information
nedbat committed Feb 10, 2025
1 parent c850f20 commit 67899ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions coverage/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,15 +1022,15 @@ def _missing__While(self, node: ast.While) -> ast.AST | None:
new_while.orelse = []
return new_while

def is_constant_expr(self, node: ast.AST) -> str | None:
def is_constant_expr(self, node: ast.AST) -> bool:
"""Is this a compile-time constant?"""
node_name = node.__class__.__name__
if node_name in ["Constant", "NameConstant", "Num"]:
return "Num"
return True
elif isinstance(node, ast.Name):
if node.id in ["True", "False", "None", "__debug__"]:
return "Name"
return None
return True
return False

# In the fullness of time, these might be good tests to write:
# while EXPR:
Expand Down

0 comments on commit 67899ea

Please sign in to comment.