type hint scanner

This commit is contained in:
2026-02-28 00:23:35 -05:00
parent 87df32c32c
commit 866b3f0fe7

View File

@@ -0,0 +1,24 @@
import ast
import sys
def get_missing_hints(file_path: str):
with open(file_path, "r", encoding="utf-8") as f:
tree = ast.parse(f.read())
missing = []
for node in ast.walk(tree):
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
has_return = node.returns is not None
args_missing = any(arg.annotation is None for arg in node.args.args if arg.arg != "self")
if not has_return or args_missing:
missing.append({
"name": node.name,
"lineno": node.lineno,
"col_offset": node.col_offset
})
return missing
if __name__ == "__main__":
if len(sys.argv) > 1:
for m in get_missing_hints(sys.argv[1]):
print(f"Line {m['lineno']}: {m['name']}")