check for print debug statement

This commit is contained in:
Aaditya Subedi 2025-11-19 12:57:00 +05:45
parent f4e025486b
commit 7c3f665ba8
2 changed files with 12 additions and 1 deletions

View file

@ -20,6 +20,11 @@ DEBUG_STATEMENTS = {
'wdb',
}
DEBUG_CALL_STATEMENTS = {
'breakpoint',
'print'
}
class Debug(NamedTuple):
line: int
@ -45,7 +50,7 @@ class DebugStatementParser(ast.NodeVisitor):
def visit_Call(self, node: ast.Call) -> None:
"""python3.7+ breakpoint()"""
if isinstance(node.func, ast.Name) and node.func.id == 'breakpoint':
if isinstance(node.func, ast.Name) and node.func.id in DEBUG_CALL_STATEMENTS:
st = Debug(node.lineno, node.col_offset, node.func.id, 'called')
self.breakpoints.append(st)
self.generic_visit(node)