-
Notifications
You must be signed in to change notification settings - Fork 36
Clean up unused imports and improve type hints #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fetch master
Removed unused imports from several entrypoint modules to reduce clutter and improve maintainability. Updated type hints for optional dictionary arguments to use modern Python syntax and avoid mutable default argument values
for more information, see https://pre-commit.ci
📝 WalkthroughWalkthroughRemoved unused imports across multiple modules, replaced mutable dict defaults with Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
Removed unused imports from prep_fp.py, run_fp.py, vasp.py, and vasp_input.py to improve code clarity and reduce clutter. Also applied minor formatting changes for better readability, such as consolidating multi-line statements and docstrings.
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #324 +/- ##
==========================================
- Coverage 84.23% 84.17% -0.07%
==========================================
Files 104 104
Lines 6129 6111 -18
==========================================
- Hits 5163 5144 -19
- Misses 966 967 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
dpgen2/entrypoint/workflow.py (1)
35-42: Good change away from mutable default; consider a slightly clearer None checkSwitching
wf_config’s default from{}toNoneand initializing inside the function removes the mutable default pitfall; that’s the right direction.To make the intent a bit clearer (and avoid re-allocating when an empty dict is intentionally passed), you could prefer an explicit
Nonecheck overor {}:def execute_workflow_subcommand( command: str, wfid: str, - wf_config: Optional[dict] = None, + wf_config: Optional[dict] = None, ): - wf_config = wf_config or {} + if wf_config is None: + wf_config = {} wf_config = normalize_args(wf_config)This keeps behavior for
Nonethe same while preserving any dict object explicitly provided by the caller.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
dpgen2/entrypoint/watch.py(1 hunks)dpgen2/entrypoint/workflow.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- dpgen2/entrypoint/watch.py
This pull request primarily removes unused imports and cleans up type annotations across several modules in the
dpgen2codebase. These changes help streamline the code, reduce unnecessary dependencies, and improve readability. Additionally, some minor logic and formatting updates are included to modernize the code and ensure consistency.Code cleanup and import removal
os,json,logging,glob,pickle, and several type hints (Set,Union, etc.) from multiple files includingmain.py,showkey.py,status.py,submit.py,watch.py,workflow.py,prep_fp.py,run_fp.py, andvasp.py. This reduces clutter and potential confusion for future maintenance. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Type annotation improvements
Optional[Dict] = {}toOptional[Dict] | None = Noneand ensuring default values are properly handled withwf_config = wf_config or {}. This makes the code safer and more in line with current Python standards. [1] [2]Minor logic and formatting updates
These changes collectively enhance code maintainability and readability without altering core functionality.This pull request primarily cleans up unused imports and improves code readability across several entrypoint modules in the
dpgen2package. It also introduces minor enhancements to type hints and default argument handling for better code clarity and robustness.Codebase cleanup and readability:
os,glob,pickle,dpdata, etc.) from multiple files includingmain.py,showkey.py,status.py,submit.py, andworkflow.pyto streamline the codebase. [1] [2] [3] [4] [5]submit.pyandwatch.py. [1] [2]Type hint and argument improvements:
watch.pyandworkflow.pyto useOptional[Dict] | None, and ensured proper default initialization usingwf_config = wf_config or {}. [1] [2]main.py. [1] [2]General code style enhancements:
submit.pyandstatus.py. [1] [2] [3]Summary by CodeRabbit
Refactor
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.