-
Notifications
You must be signed in to change notification settings - Fork 1
extend ruff linter #315
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
extend ruff linter #315
Conversation
WalkthroughThe pull request introduces several changes across configuration and source code files. It broadens the ruff linting scope by simplifying hook arguments and adds a dedicated ruff configuration via the project file. Several modules now explicitly declare their public API using Changes
Sequence Diagram(s)Possibly related PRs
Poem
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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 (2)
structuretoolkit/analyse/phonopy.py (1)
22-22: Update docstring to match the modernized return type annotation.The return type annotation has been modernized to use
list[int], but the docstring still showsList[int]. Update the docstring for consistency.- List[int]: The indices of equivalent atoms. + list[int]: The indices of equivalent atoms.Also applies to: 33-33
structuretoolkit/analyse/dscribe.py (1)
38-38: Update docstring to reflect new default value.The docstring still shows the old default value for the compression parameter.
- compression (dict, optional): The compression settings. Defaults to {"mode": "off", "species_weighting": None}. + compression (dict, optional): The compression settings. Defaults to None, which sets {"mode": "off", "species_weighting": None}.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
.pre-commit-config.yaml(1 hunks)pyproject.toml(1 hunks)structuretoolkit/__init__.py(1 hunks)structuretoolkit/analyse/__init__.py(1 hunks)structuretoolkit/analyse/dscribe.py(2 hunks)structuretoolkit/analyse/neighbors.py(14 hunks)structuretoolkit/analyse/phonopy.py(1 hunks)structuretoolkit/analyse/pyscal.py(3 hunks)structuretoolkit/analyse/snap.py(9 hunks)structuretoolkit/analyse/spatial.py(4 hunks)structuretoolkit/analyse/strain.py(2 hunks)structuretoolkit/analyse/symmetry.py(0 hunks)structuretoolkit/build/__init__.py(1 hunks)structuretoolkit/build/aimsgb.py(1 hunks)structuretoolkit/build/mesh.py(2 hunks)structuretoolkit/build/random.py(3 hunks)structuretoolkit/build/sqs.py(10 hunks)structuretoolkit/common/__init__.py(1 hunks)structuretoolkit/common/helper.py(1 hunks)structuretoolkit/visualize.py(11 hunks)
💤 Files with no reviewable changes (1)
- structuretoolkit/analyse/symmetry.py
✅ Files skipped from review due to trivial changes (2)
- structuretoolkit/analyse/spatial.py
- structuretoolkit/build/init.py
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: build (ubuntu-latest, 3.12, linux-64-py-3-12, /usr/share/miniconda3/envs/my-env)
- GitHub Check: build (macos-latest, 3.12, osx-64-py-3-12, /Users/runner/miniconda3/envs/my-env)
- GitHub Check: build (windows-latest, 3.12, win-64-py-3-12, C:\Miniconda3\envs\my-env)
🔇 Additional comments (28)
structuretoolkit/common/__init__.py (1)
19-34: Well-structured__all__declaration!The explicit list of public exports matches the imported entities and improves API clarity.
structuretoolkit/analyse/dscribe.py (1)
16-16: Good fix for mutable default argument!Moving the dictionary initialization from the parameter default to runtime is a good practice to avoid potential issues with mutable defaults.
Also applies to: 53-54
structuretoolkit/build/random.py (3)
5-5: Good modernization of type hints!The type hints have been updated to use built-in collection types (PEP 585), which is the recommended approach in modern Python.
Also applies to: 21-23, 28-28
10-13: Nice improvement to tqdm import error handling!The fallback implementation for when tqdm is not available is clean and maintains the expected interface.
103-106: Good addition of stacklevel to warning!Adding
stacklevel=2helps users identify the actual source of the warning in their code rather than in the library internals.structuretoolkit/__init__.py (1)
101-158: LGTM! Well-structured public API declaration.The
__all__list is comprehensive and accurately reflects all the imported functions, providing a clear interface for users of the module.structuretoolkit/build/aimsgb.py (1)
98-98: LGTM! Improved warning message with proper stack tracing.Adding
stacklevel=2helps users by showing where the deprecated parameter is used rather than where the warning is defined.structuretoolkit/analyse/__init__.py (1)
259-292: LGTM! Comprehensive public API declaration.The
__all__list accurately includes all imported and defined functions, providing a clear interface for the module.structuretoolkit/build/sqs.py (4)
4-6: LGTM! Updated imports and type hints.Using
collections.abcforIterableand removing unused imports improves code organization.
33-50: LGTM! Modernized type hints.Updated type hints from
Dicttodictalign with PEP 585, which allows using built-in types as generic types.
67-67: LGTM! Improved string formatting and warnings.
- Updated string concatenation to f-strings for better readability
- Added
stacklevel=2to warnings for better error reportingAlso applies to: 79-82, 95-99
210-225: LGTM! Improved dictionary structure.Settings dictionary is now more readable with consistent indentation and line breaks.
structuretoolkit/analyse/pyscal.py (2)
30-30: LGTM! Type hint modernization.The change from
Tupletotuplealigns with modern Python type hinting practices, as built-in types are now supported for simple type hints.
83-83: LGTM! Type hint modernization.The change from
Dicttodictaligns with modern Python type hinting practices, as built-in types are now supported for simple type hints.structuretoolkit/common/helper.py (1)
248-248: LGTM! Improved code readability.The conditional assignment has been simplified using a ternary operator, making the code more concise without sacrificing clarity.
structuretoolkit/analyse/strain.py (2)
235-235: LGTM! Simplified list conversion.The change improves readability by directly converting dictionary keys and values to lists.
253-253: LGTM! Simplified conditional check.Using tuple membership check
in ("fcc", "hcp")is more concise than the previousorcondition.structuretoolkit/analyse/snap.py (3)
67-67: LGTM! Improved parameter handling.Setting
element_radiusdefault to None with a fallback value of[4.0]improves flexibility while maintaining backward compatibility.Also applies to: 95-96
427-428: LGTM! Simplified dictionary check.Removed unnecessary
.keys()call when checking for dictionary key presence.
685-685: LGTM! Simplified conditional assignment.Using a ternary operator for
wjassignment improves code readability..pre-commit-config.yaml (1)
7-7: LGTM! Simplified ruff hook arguments.The change broadens the scope of linting by removing the
--select Ifilter, which is now handled by the detailed configuration inpyproject.toml.pyproject.toml (1)
66-111: LGTM! Comprehensive ruff linting configuration.The configuration is well-structured with:
- Clear exclusions for non-source directories
- Comprehensive selection of linting rules (pycodestyle, Pyflakes, pyupgrade, etc.)
- Well-documented rule ignores with clear justifications
structuretoolkit/visualize.py (1)
106-108: LGTM! Improved warning messages with proper stack tracing.The changes consistently enhance warning messages by:
- Adding
stacklevel=2to show the correct source location in the traceback- Using consistent string concatenation style
Also applies to: 145-147, 405-410, 416-417, 458-460
structuretoolkit/analyse/neighbors.py (3)
368-368: LGTM! Updated type hints to use built-in types.The changes align with modern Python type hinting practices by using built-in types (
list,tuple) instead of capitalized types fromtypingmodule.Also applies to: 1011-1011, 1228-1228, 1261-1261
636-643: LGTM! Simplified boolean expression.The
_check_widthmethod has been improved by combining multiple conditions into a single boolean expression, enhancing readability.
1275-1280: LGTM! Improved code structure.The
__probe_clustermethod's structure has been enhanced with better indentation and a clearer conditional block.structuretoolkit/build/mesh.py (2)
3-3: LGTM! Clean import changes.The addition of the
aseimport and removal of unused imports (typing,warnings) aligns with the modernized type annotations.
14-16: LGTM! Modern type annotations.The type annotations are correctly updated to use Python 3.10's union operator syntax, improving readability while maintaining the same type constraints.
Please ensure that the project's minimum Python version requirement is documented as 3.10 or higher in the project metadata (e.g.,
setup.py,pyproject.toml), as these type annotations use the union operator syntax (|) introduced in Python 3.10.
Summary by CodeRabbit