🧹 [Code Health] Remove duplicated sys.path boilerplate from Scripts#149
🧹 [Code Health] Remove duplicated sys.path boilerplate from Scripts#149Ven0m0 wants to merge 1 commit into
Conversation
Co-authored-by: Ven0m0 <82972344+Ven0m0@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Current Aviator status
This PR is currently in state
See the real-time status of this PR on the
Aviator webapp.
Use the Aviator Chrome Extension
to see the status of your PR within GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the codebase's health by eliminating duplicated Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Removes repetitive sys.path manipulation in Scripts/ Python scripts and tests, relying instead on the existing unittest discover Scripts/ ... invocation and normal script execution semantics for local imports.
Changes:
- Removed
sys.pathboilerplate from multiple Python scripts/tests underScripts/. - Updated
test_update_lists.pyto loadupdate-lists.pyvia a path relative to the test file. - Simplified several test modules by dropping now-unneeded imports (
sys,Path) tied to the removedsys.pathlogic.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Scripts/update-lists.py | Removes local sys.path injection before importing common. |
| Scripts/test_update_lists.py | Loads update-lists.py using Path(__file__).parent for robust path resolution. |
| Scripts/test_is_pure_domain_logic.py | Removes sys.path setup and related imports at the top of the test. |
| Scripts/test_deduplicate.py | Removes sys.path setup and related imports. |
| Scripts/test_common.py | Removes sys.path setup and related imports. |
| Scripts/move-pure-domains.py | Removes local sys.path injection before importing common. |
| Scripts/deduplicate.py | Removes local sys.path injection before importing common. |
| # Add current directory to path to allow importing common if run from elsewhere | ||
| if str(Path(__file__).parent) not in sys.path: | ||
| sys.path.append(str(Path(__file__).parent)) | ||
|
|
||
| from common import is_valid_domain, write_lines |
There was a problem hiding this comment.
The comment about adding the script directory to sys.path is now stale since the sys.path modification was removed. Please remove or update this comment to avoid misleading future readers.
| # Add current directory to path to allow importing deduplicate | ||
| if str(Path(__file__).parent) not in sys.path: | ||
| sys.path.append(str(Path(__file__).parent)) | ||
|
|
||
| from deduplicate import process_content |
There was a problem hiding this comment.
This comment indicates the test adjusts sys.path, but that code was removed. Please delete or reword the comment so it matches the current import strategy (relying on unittest discover adding Scripts/ to sys.path).
| # Add current directory to path | ||
| if str(Path(__file__).parent) not in sys.path: | ||
| sys.path.append(str(Path(__file__).parent)) | ||
|
|
||
| from common import sanitize_filename, is_valid_domain, is_adguard_rule |
There was a problem hiding this comment.
The "Add current directory to path" comment is now inaccurate after removing the sys.path modification. Please remove/update it to prevent confusion about how common is imported in tests.
There was a problem hiding this comment.
Code Review
This pull request correctly removes boilerplate sys.path modifications from several Python scripts, which is a good code health improvement. My review includes a few suggestions to also remove the now-misleading or orphaned comments associated with the removed code to complete the cleanup.
I am having trouble creating individual review comments. Click here to see my feedback.
Scripts/deduplicate.py (17-18)
While removing this sys.path modification is correct, the comment on line 16 (# Add current directory to path to allow importing common if run from elsewhere) is now misleading and should also be removed as part of this code health improvement.
Scripts/test_common.py (7-8)
This sys.path modification is correctly removed. However, the comment on line 6 (# Add current directory to path) is now orphaned and should also be removed.
Scripts/test_deduplicate.py (6-7)
This sys.path modification is correctly removed. However, the comment on line 5 (# Add current directory to path to allow importing deduplicate) is now orphaned and should also be removed.
| from pathlib import Path | ||
| import hashlib | ||
|
|
||
| # Add current directory to path |
There was a problem hiding this comment.
WARNING: Orphaned comment - the sys.path manipulation code this comment referred to has been removed. This comment is now misleading and should be removed.
| import sys | ||
| from pathlib import Path | ||
|
|
||
| # Add current directory to path to allow importing deduplicate |
There was a problem hiding this comment.
WARNING: Orphaned comment - the sys.path manipulation code this comment referred to has been removed. This comment is now misleading and should be removed.
Code Review SummaryStatus: 1 Critical Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
Inline Comments Posted
Files Reviewed (7 files)
Recommendation: The sys.path manipulation should either be:
The tests don't need the sys.path manipulation since they run via |
🎯 What: Removed duplicated
sys.pathmodification boilerplate from Python scripts and test files insideScripts/. Refactored tests to rely onunittest discoverpaths instead of dynamically injecting directory parents.💡 Why: Modifying
sys.pathvia boilerplate across many files adds tech debt, confusing module paths, and is unpythonic. By relying on native working directory resolution when executing tests (cd Scripts && python3 -m unittest discover -p 'test_*.py'), we eliminate the duplication and retain local imports seamlessly.✅ Verification: Verified changes by executing
bash run_pre_commit.sh, validating linting and formats viauv run ruff check/uv run ruff format, and ensuring the exact test suite output identically matched execution before thesys.pathchanges.✨ Result: A cleaner codebase absent of repetitive file path inspection and sys path injections.
PR created automatically by Jules for task 4625015370076301560 started by @Ven0m0