Skip to content

Commit 3dce740

Browse files
committed
Fix up type annotations
1 parent 1ec17a5 commit 3dce740

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Tools/cases_generator/analyzer.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def visit(stmt: Stmt) -> None:
723723
if error is not None:
724724
raise analysis_error(f"Escaping call '{error.text} in condition", error)
725725

726-
def escaping_call_in_simple_stmt(stmt: SimpleStmt, result: dict[Stmt, EscapingCall]):
726+
def escaping_call_in_simple_stmt(stmt: SimpleStmt, result: dict[SimpleStmt, EscapingCall]) -> None:
727727
tokens = stmt.contents
728728
for idx, tkn in enumerate(tokens):
729729
try:
@@ -826,9 +826,9 @@ def stack_effect_only_peeks(instr: parser.InstDef) -> bool:
826826
)
827827

828828

829-
def op_escapes(op: parser.CodeDef):
829+
def op_escapes(op: parser.CodeDef) -> bool:
830830

831-
def is_simple_exit(stmt: Stmt):
831+
def is_simple_exit(stmt: Stmt) -> bool:
832832
if not isinstance(stmt, SimpleStmt):
833833
return False
834834
tokens = stmt.contents
@@ -844,7 +844,7 @@ def is_simple_exit(stmt: Stmt):
844844
tokens[3].text == ")"
845845
)
846846

847-
def escapes_list(stmts: list[Stmt]):
847+
def escapes_list(stmts: list[Stmt]) -> bool:
848848
if not stmts:
849849
return False
850850
if is_simple_exit(stmts[-1]):
@@ -854,14 +854,14 @@ def escapes_list(stmts: list[Stmt]):
854854
return True
855855
return False
856856

857-
def escapes(stmt: Stmt) -> None:
857+
def escapes(stmt: Stmt) -> bool:
858858
if isinstance(stmt, BlockStmt):
859859
return escapes_list(stmt.body)
860860
elif isinstance(stmt, SimpleStmt):
861861
for tkn in stmt.contents:
862862
if tkn.text == "DECREF_INPUTS":
863863
return True
864-
d: dict[Stmt, EscapingCall] = {}
864+
d: dict[SimpleStmt, EscapingCall] = {}
865865
escaping_call_in_simple_stmt(stmt, d)
866866
return bool(d)
867867
elif isinstance(stmt, IfStmt):
@@ -876,6 +876,8 @@ def escapes(stmt: Stmt) -> None:
876876
return escapes(stmt.body)
877877
elif isinstance(stmt, WhileStmt):
878878
return escapes(stmt.body)
879+
else:
880+
assert False, "Unexpected statement type"
879881

880882
return escapes(op.block)
881883

0 commit comments

Comments
 (0)