From 67e1df285ab5d890972b0c16705e63907f40ebbd 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:25:24 +0000 Subject: [PATCH 1/2] test(generator): add direct test for empty __all__ tuple generation Adds `test_generate_all_tuple_empty` to `tests/test_generator.py` to directly verify that `_generate_all_tuple([])` returns `"__all__ = ()"`. This closes a testing gap in the coverage. Also fixes a failing test related to `tests/fixtures/sample_type_aliases.py` where supposed pre-Python 3.12 type aliases incorrectly used the Python 3.12 `type` syntax. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- tests/fixtures/sample_type_aliases.py | 16 +++++++++------- tests/test_generator.py | 6 ++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/fixtures/sample_type_aliases.py b/tests/fixtures/sample_type_aliases.py index 0e1426c..31e6a12 100644 --- a/tests/fixtures/sample_type_aliases.py +++ b/tests/fixtures/sample_type_aliases.py @@ -20,13 +20,15 @@ test_file_path: FilePath | None = None # 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] +from typing import TypeAlias + +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 diff --git a/tests/test_generator.py b/tests/test_generator.py index 6354058..e0c7ebc 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -538,6 +538,12 @@ def test_validate_init_file_missing_all(temp_dir: Path): # Sorting tests +def test_generate_all_tuple_empty(generator: CodeGenerator): + """Test generating __all__ tuple with empty exports list.""" + result = generator._generate_all_tuple([]) + assert result == "__all__ = ()" + + def test_export_sorting_screaming_snake_pascal_snake(generator: CodeGenerator): """Test exports are sorted by custom key: SCREAMING_SNAKE, PascalCase, snake_case.""" exports = [ From f3bad7166dea6e33a5396d1ce2e4a11b917445f8 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:27:52 +0000 Subject: [PATCH 2/2] test(generator): fix ruff error in sample_type_aliases.py Fixes a linting error introduced in the previous commit. The `tests/fixtures/sample_type_aliases.py` file uses intentional legacy syntax to test backwards compatibility in the `ASTParser`. Ignoring rule UP040 prevents ruff from automatically rewriting these to use the new `type` keyword, avoiding tests from breaking in CI. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- ruff.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ruff.toml b/ruff.toml index 30145e3..605bb71 100755 --- a/ruff.toml +++ b/ruff.toml @@ -32,6 +32,7 @@ exclude = [ "venv", "typings", "tests/fixtures/malformed.py", + "tests/fixtures/sample_type_aliases.py", ] extend-include = ["*.ipynb"] fix = true @@ -157,6 +158,9 @@ exclude = [ convention = "google" [lint.per-file-ignores] +"tests/fixtures/sample_type_aliases.py" = [ + "UP040", # Type alias uses `TypeAlias` annotation instead of the `type` keyword +] "tests/*.py" = [ "ANN", "C901", # too complex