diff --git a/src/exportify/validator/validator.py b/src/exportify/validator/validator.py index d241d69..85bf4ca 100644 --- a/src/exportify/validator/validator.py +++ b/src/exportify/validator/validator.py @@ -139,11 +139,11 @@ def _check_structure_and_imports( if not isinstance(tree, ast.Module): return has_type_checking_block, has_lateimport_calls - for i, node in enumerate(tree.body): + for node in tree.body: is_import = isinstance(node, (ast.Import, ast.ImportFrom)) is_code = self._is_code_statement(node, is_import=is_import) - if is_import and seen_code and not self._is_type_checking_block(tree.body[:i]): + if is_import and seen_code: issues.append( ValidationWarning( file=file_path, @@ -514,15 +514,12 @@ def _is_type_checking_guard(self, node: ast.If) -> bool: """ return isinstance(node.test, ast.Name) and node.test.id == "TYPE_CHECKING" - def _is_type_checking_block(self, nodes: list[ast.stmt]) -> bool: + def _is_type_checking_block(self) -> bool: """Check if we're currently in a TYPE_CHECKING block. This is a simplified check - it just looks for any TYPE_CHECKING if in the nodes. More sophisticated tracking would be needed for nested structures. - Args: - nodes: List of AST nodes to check (body up to current position) - Returns: True if there's a TYPE_CHECKING block in the nodes (simplified) """