Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/exportify/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
"""
Expand Down
Loading