feat(types): Complete strict static analysis and typing track

This commit is contained in:
2026-03-04 09:46:02 -05:00
parent c6c2a1b40c
commit fe2114a2e0
46 changed files with 606 additions and 795 deletions

View File

@@ -6,7 +6,7 @@ This file is kept so that any stale imports do not break.
"""
from pathlib import Path
from typing import Optional
from typing import Optional, Any, List, Tuple, Dict
import tree_sitter
import tree_sitter_python
@@ -33,15 +33,15 @@ class ASTParser:
Returns a skeleton of a Python file (preserving docstrings, stripping function bodies).
"""
tree = self.parse(code)
edits = []
edits: List[Tuple[int, int, str]] = []
def is_docstring(node):
def is_docstring(node: tree_sitter.Node) -> bool:
if node.type == "expression_statement" and node.child_count > 0:
if node.children[0].type == "string":
return True
return False
def walk(node):
def walk(node: tree_sitter.Node) -> None:
if node.type == "function_definition":
body = node.child_by_field_name("body")
if body and body.type == "block":
@@ -77,15 +77,15 @@ class ASTParser:
Otherwise strips bodies but preserves docstrings.
"""
tree = self.parse(code)
edits = []
edits: List[Tuple[int, int, str]] = []
def is_docstring(node):
def is_docstring(node: tree_sitter.Node) -> bool:
if node.type == "expression_statement" and node.child_count > 0:
if node.children[0].type == "string":
return True
return False
def has_core_logic_decorator(node):
def has_core_logic_decorator(node: tree_sitter.Node) -> bool:
# Check if parent is decorated_definition
parent = node.parent
if parent and parent.type == "decorated_definition":
@@ -96,7 +96,7 @@ class ASTParser:
return True
return False
def has_hot_comment(func_node):
def has_hot_comment(func_node: tree_sitter.Node) -> bool:
# Check all descendants of the function_definition for a [HOT] comment
stack = [func_node]
while stack:
@@ -109,7 +109,7 @@ class ASTParser:
stack.append(child)
return False
def walk(node):
def walk(node: tree_sitter.Node) -> None:
if node.type == "function_definition":
body = node.child_by_field_name("body")
if body and body.type == "block":
@@ -153,5 +153,6 @@ def get_file_id(path: Path) -> Optional[str]:
def evict(path: Path) -> None:
pass
def list_cached() -> list[dict]:
def list_cached() -> List[Dict[str, Any]]:
return []