From 3c956e671a36e402f027f858ec61a976f30b0875 Mon Sep 17 00:00:00 2001 From: varun-r-mallya Date: Thu, 2 Oct 2025 01:11:54 +0530 Subject: [PATCH] add static type checking Signed-off-by: varun-r-mallya --- pythonbpf/functions_pass.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pythonbpf/functions_pass.py b/pythonbpf/functions_pass.py index 0533431..e1a5b1c 100644 --- a/pythonbpf/functions_pass.py +++ b/pythonbpf/functions_pass.py @@ -608,7 +608,7 @@ def func_proc(tree, module, chunks, map_sym_tab, structs_sym_tab): ) -def infer_return_type(func_node: ast.FunctionDef): +def infer_return_type(func_node: ast.FunctionDef) -> str | None | Any: if not isinstance(func_node, (ast.FunctionDef, ast.AsyncFunctionDef)): raise TypeError("Expected ast.FunctionDef") if func_node.returns is not None: @@ -656,9 +656,9 @@ def infer_return_type(func_node: ast.FunctionDef): except Exception: return type(e).__name__ - for node in ast.walk(func_node): - if isinstance(node, ast.Return): - t = _expr_type(node.value) + for walked_node in ast.walk(func_node): + if isinstance(walked_node, ast.Return): + t = _expr_type(walked_node.value) if found_type is None: found_type = t elif found_type != t: