@@ -52,19 +52,7 @@ def __init__(
5252 self .resolver = ImportResolver (project_root = self .project_root )
5353 self .consistency_checker = ConsistencyChecker (project_root = self .project_root )
5454
55- def validate_file (self , file_path : Path ) -> list [ValidationError | ValidationWarning ]:
56- """Validate a single Python file.
57-
58- Args:
59- file_path: Path to Python file to validate
60-
61- Returns:
62- List of validation errors and warnings
63- """
64- issues , _ , _ = self ._validate_file_with_metrics (file_path )
65- return issues
66-
67- def _validate_file_with_metrics (
55+ def validate_file (
6856 self , file_path : Path
6957 ) -> tuple [list [ValidationError | ValidationWarning ], int , ast .AST | None ]:
7058 """Validate a single Python file and count lateimport calls.
@@ -151,11 +139,11 @@ def _check_structure_and_imports(
151139 if not isinstance (tree , ast .Module ):
152140 return has_type_checking_block , has_lateimport_calls
153141
154- for i , node in enumerate ( tree .body ) :
142+ for node in tree .body :
155143 is_import = isinstance (node , (ast .Import , ast .ImportFrom ))
156144 is_code = self ._is_code_statement (node , is_import = is_import )
157145
158- if is_import and seen_code and not self . _is_type_checking_block ( tree . body [: i ]) :
146+ if is_import and seen_code :
159147 issues .append (
160148 ValidationWarning (
161149 file = file_path ,
@@ -252,7 +240,7 @@ def validate_files(self, file_paths: list[Path]) -> list[ValidationError | Valid
252240 """
253241 all_issues : list [ValidationError | ValidationWarning ] = []
254242 for file_path in file_paths :
255- issues = self .validate_file (file_path )
243+ issues , _ , _ = self .validate_file (file_path )
256244 all_issues .extend (issues )
257245 return all_issues
258246
@@ -286,7 +274,7 @@ def validate(self, file_paths: list[Path] | None = None) -> ValidationReport:
286274 parsed_trees : dict [Path , ast .AST ] = {}
287275
288276 for file_path in file_paths :
289- results , count , tree = self ._validate_file_with_metrics (file_path )
277+ results , count , tree = self .validate_file (file_path )
290278
291279 # Separate errors and warnings
292280 errors = [r for r in results if isinstance (r , ValidationError )]
@@ -526,15 +514,12 @@ def _is_type_checking_guard(self, node: ast.If) -> bool:
526514 """
527515 return isinstance (node .test , ast .Name ) and node .test .id == "TYPE_CHECKING"
528516
529- def _is_type_checking_block (self , nodes : list [ ast . stmt ] ) -> bool :
517+ def _is_type_checking_block (self ) -> bool :
530518 """Check if we're currently in a TYPE_CHECKING block.
531519
532520 This is a simplified check - it just looks for any TYPE_CHECKING if in the nodes.
533521 More sophisticated tracking would be needed for nested structures.
534522
535- Args:
536- nodes: List of AST nodes to check (body up to current position)
537-
538523 Returns:
539524 True if there's a TYPE_CHECKING block in the nodes (simplified)
540525 """
0 commit comments