Skip to content

🧹 refactor: remove unused nodes argument in validator.py#10

Merged
bashandbone merged 4 commits intomainfrom
chore/remove-unused-nodes-argument-18343041253122866935
Mar 13, 2026
Merged

🧹 refactor: remove unused nodes argument in validator.py#10
bashandbone merged 4 commits intomainfrom
chore/remove-unused-nodes-argument-18343041253122866935

Conversation

@bashandbone
Copy link
Contributor

🎯 What: The code health issue addressed
The nodes parameter was defined in _is_type_checking_block but it was not used within the method's body. Furthermore, the single caller to this method (_check_structure_and_imports) iterated over the tree.body using enumerate just so it could slice tree.body[:i] and pass it to this method.

💡 Why: How this improves maintainability
Removing an unused parameter directly declutters the method signature and reduces cognitive load when reading the implementation. In addition, updating the caller simplifies the code, allowing us to drop enumerate and a slice operation, thereby creating a cleaner loop and avoiding confusing variables that have no impact on execution.

Verification: How you confirmed the change is safe
Ran uv run pytest specifically on tests/test_validator.py as well as the overall test suite. No new failures were introduced. Also ran uv run ruff check which caught the unused i variable in the enumerate, allowing me to completely clean up that loop.

Result: The improvement achieved
A cleaner and slightly more efficient implementation of _check_structure_and_imports and _is_type_checking_block.


PR created automatically by Jules for task 18343041253122866935 started by @bashandbone

- 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>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings March 13, 2026 02:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors LateImportValidator to remove an unused nodes parameter from _is_type_checking_block and simplify the import-structure scan loop.

Changes:

  • Remove unused nodes argument from _is_type_checking_block.
  • Simplify _check_structure_and_imports loop by dropping enumerate and list slicing.
Comments suppressed due to low confidence (1)

src/exportify/validator/validator.py:540

  • After removing the nodes parameter, this method no longer has any context to determine whether we are "in a TYPE_CHECKING block", yet the docstring still describes scanning nodes and the implementation unconditionally returns False. Please either (a) remove this method entirely and simplify callers, or (b) redesign it to accept the necessary AST context (e.g., current index/body or a node) and implement the described check, and update the docstring accordingly.
    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.

        Returns:
            True if there's a TYPE_CHECKING block in the nodes (simplified)
        """
        # For now, just return False - this is too simplistic
        # The real check needs to track nesting depth and current scope
        return False

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- 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>
type ErrorMessage = str
type ConfigDict = dict[str, str | int | bool | list[str]]
type NamePair = tuple[str, str]
FilePath: TypeAlias = str | Path
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

bashandbone and others added 2 commits March 12, 2026 23:28
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>
…53122866935

Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
@bashandbone bashandbone merged commit 258fe85 into main Mar 13, 2026
8 of 9 checks passed
@bashandbone bashandbone deleted the chore/remove-unused-nodes-argument-18343041253122866935 branch March 13, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants