From 25f97cfc4467ec2c4f699ee173fbc36ac4f43909 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 02:28:31 +0000 Subject: [PATCH 1/3] refactor: remove unused `nodes` argument from `_is_type_checking_block` - Removed the unused `nodes` argument from the method signature. - Removed associated parameter documentation in the method's docstring. - Updated the single invocation site in `_check_structure_and_imports` to pass zero arguments. - Removed the `enumerate(tree.body)` loop as the index was only used to pass `tree.body[:i]` to the method. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- src/exportify/validator/validator.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/exportify/validator/validator.py b/src/exportify/validator/validator.py index 489322b..08c2853 100644 --- a/src/exportify/validator/validator.py +++ b/src/exportify/validator/validator.py @@ -151,11 +151,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 and not self._is_type_checking_block(): issues.append( ValidationWarning( file=file_path, @@ -526,15 +526,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) """ From 1134c6f2f9a2e816786be7fe31ded64fc543c05f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 02:33:21 +0000 Subject: [PATCH 2/3] fix: test failure in real project files type alias detection - Converted the "pre-3.12" aliases in `tests/fixtures/sample_type_aliases.py` to correctly use the legacy syntax (`TypeAlias`) from `typing` instead of mistakenly using the modern `type X = Y` syntax, which broke the `ast_parser` detecting the legacy style in `tests/test_type_alias_detection.py::TestRealProjectFiles::test_real_fixture_file_has_both_alias_styles`. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- tests/fixtures/sample_type_aliases.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/fixtures/sample_type_aliases.py b/tests/fixtures/sample_type_aliases.py index 0e1426c..2b38ea6 100644 --- a/tests/fixtures/sample_type_aliases.py +++ b/tests/fixtures/sample_type_aliases.py @@ -19,14 +19,17 @@ # Dummy usage of type aliases to keep static analyzers happy. test_file_path: FilePath | None = None +# ruff: noqa: UP040 +from typing import TypeAlias + # Pre-3.12 style type aliases (X: TypeAlias = Y) -type FilePath = str | Path -type ModuleName = str -type RulePattern = str -type ExportName = str -type ErrorMessage = str -type ConfigDict = dict[str, str | int | bool | list[str]] -type NamePair = tuple[str, str] +FilePath: TypeAlias = str | Path +ModuleName: TypeAlias = str +RulePattern: TypeAlias = str +ExportName: TypeAlias = str +ErrorMessage: TypeAlias = str +ConfigDict: TypeAlias = dict[str, str | int | bool | list[str]] +NamePair: TypeAlias = tuple[str, str] # Python 3.12+ style type aliases (type X = Y) type FileContent = str From 33902a5ed1575ed1ba63fe70855c60c630943881 Mon Sep 17 00:00:00 2001 From: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com> Date: Thu, 12 Mar 2026 23:28:23 -0400 Subject: [PATCH 3/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com> --- src/exportify/validator/validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exportify/validator/validator.py b/src/exportify/validator/validator.py index 08c2853..1ed403b 100644 --- a/src/exportify/validator/validator.py +++ b/src/exportify/validator/validator.py @@ -155,7 +155,7 @@ def _check_structure_and_imports( 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(): + if is_import and seen_code: issues.append( ValidationWarning( file=file_path,