-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add ruff formatter #205
Add ruff formatter #205
Conversation
WalkthroughThe recent updates enhance the robustness and readability of the Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
for more information, see https://pre-commit.ci
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: 5
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- .ci_support/release.py (3 hunks)
- .pre-commit-config.yaml (1 hunks)
- docs/source/conf.py (1 hunks)
- pylammpsmpi/init.py (1 hunks)
- pylammpsmpi/mpi/lmpmpi.py (3 hunks)
- pylammpsmpi/wrapper/concurrent.py (2 hunks)
- setup.py (1 hunks)
- tests/test_ase_interface.py (8 hunks)
- tests/test_base.py (3 hunks)
- tests/test_concurrent.py (3 hunks)
- tests/test_pylammpsmpi_local.py (4 hunks)
Files skipped from review due to trivial changes (6)
- .pre-commit-config.yaml
- pylammpsmpi/mpi/lmpmpi.py
- pylammpsmpi/wrapper/concurrent.py
- setup.py
- tests/test_ase_interface.py
- tests/test_pylammpsmpi_local.py
Additional Context Used
Ruff (5)
.ci_support/release.py (4)
3-3: Ambiguous variable name:
l
25-25: Ambiguous variable name:
l
46-46: Ambiguous variable name:
l
49-49: Ambiguous variable name:
l
docs/source/conf.py (1)
32-32: Module level import not at top of file
Additional comments not posted (10)
pylammpsmpi/__init__.py (1)
11-15
: The try-except block for importingLammpsASELibrary
is correctly implemented to handle the optional dependency onase
.docs/source/conf.py (1)
9-9
: Standardizing string quotations to double quotes improves consistency.Also applies to: 16-16, 18-18, 25-25, 26-26
.ci_support/release.py (1)
55-69
: The main block for handling dependencies and versions is appropriately updated to improve robustness.tests/test_concurrent.py (4)
17-17
: Adding a comma at the end of thecmdargs
list improves consistency.
97-99
: Reformatting the assertion intest_version
improves readability.
104-107
: Adding a comma at the end of the list intest_extract_global
improves consistency.
118-120
: Reformatting the assertion intest_properties
improves readability.tests/test_base.py (3)
21-21
: Comma added for better readability.
34-34
: Comma added for better readability.
117-117
: Comma added for better readability.
@@ -4,10 +4,14 @@ | |||
from pylammpsmpi.wrapper.concurrent import LammpsConcurrent | |||
from pylammpsmpi.wrapper.base import LammpsBase | |||
|
|||
|
|||
__all__ = [LammpsLibrary, LammpsConcurrent, LammpsBase] |
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.
Ensure LammpsASELibrary
is only added to __all__
when ase
is installed.
- __all__ = [LammpsLibrary, LammpsConcurrent, LammpsBase]
+ __all__ = [LammpsLibrary, LammpsConcurrent, LammpsBase, "LammpsASELibrary"]
The __all__
list should include "LammpsASELibrary"
as a string to avoid potential issues when ase
is not installed.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
__all__ = [LammpsLibrary, LammpsConcurrent, LammpsBase] | |
__all__ = [LammpsLibrary, LammpsConcurrent, LammpsBase, "LammpsASELibrary"] |
main(["-e", "-o", "apidoc", "../../pylammpsmpi/", "--force"]) |
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.
Move the import statement for main
to the top of the file to follow best practices for module-level imports.
- from sphinx.ext.apidoc import main
- main(["-e", "-o", "apidoc", "../../pylammpsmpi/", "--force"])
+ from sphinx.ext.apidoc import main
# -- Generate API documentation ----------------------------------------------
# https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html
main(["-e", "-o", "apidoc", "../../pylammpsmpi/", "--force"])
Module-level imports should be at the top of the file.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
main(["-e", "-o", "apidoc", "../../pylammpsmpi/", "--force"]) | |
from sphinx.ext.apidoc import main | |
# -- Generate API documentation ---------------------------------------------- | |
# https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html | |
main(["-e", "-o", "apidoc", "../../pylammpsmpi/", "--force"]) |
@@ -1,12 +1,19 @@ | |||
def get_setup_version_and_pattern(setup_content): | |||
depend_lst, version_lst = [], [] | |||
for l in setup_content: |
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.
Rename the variable l
to a more descriptive name to improve code readability.
- for l in setup_content:
- if "==" in l:
- lst = (
- l.split("[")[-1]
- .split("]")[0]
- .replace(" ", "")
- .replace('"', "")
- .replace("'", "")
- .split(",")
- )
- for dep in lst:
- if dep != "\n":
- version_lst.append(dep.split("==")[1])
- depend_lst.append(dep.split("==")[0])
+ for line in setup_content:
+ if "==" in line:
+ lst = (
+ line.split("[")[-1]
+ .split("]")[0]
+ .replace(" ", "")
+ .replace('"', "")
+ .replace("'", "")
+ .split(",")
+ )
+ for dep in lst:
+ if dep != "\n":
+ version_lst.append(dep.split("==")[1])
+ depend_lst.append(dep.split("==")[0])
The variable name l
is ambiguous and should be renamed to line
for better readability.
Also applies to: 26-26, 46-46, 49-49
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
for l in setup_content: | |
for line in setup_content: |
@@ -16,14 +23,14 @@ | |||
read_flag = False | |||
depend_lst, version_lst = [], [] | |||
for l in env_content: | |||
if 'dependencies:' in l: | |||
if "dependencies:" in l: |
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.
Rename the variable l
to a more descriptive name to improve code readability.
- for l in env_content:
- if "dependencies:" in l:
- read_flag = True
- elif read_flag:
- lst = l.replace("-", "").replace(" ", "").replace("\n", "").split("=")
- if len(lst) == 2:
- depend_lst.append(lst[0])
- version_lst.append(lst[1])
+ for line in env_content:
+ if "dependencies:" in line:
+ read_flag = True
+ elif read_flag:
+ lst = line.replace("-", "").replace(" ", "").replace("\n", "").split("=")
+ if len(lst) == 2:
+ depend_lst.append(lst[0])
+ version_lst.append(lst[1])
The variable name l
is ambiguous and should be renamed to line
for better readability.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if "dependencies:" in l: | |
if "dependencies:" in line: |
@@ -35,27 +42,29 @@ | |||
version_combo_dict[dep] = dep + "==" + ver | |||
|
|||
setup_content_new = "" | |||
pattern_dict = {d:d + "==" + v for d, v in version_high_dict.items()} | |||
pattern_dict = {d: d + "==" + v for d, v in version_high_dict.items()} | |||
for l in setup_content: |
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.
Rename the variable l
to a more descriptive name to improve code readability.
- for l in setup_content:
- for k, v in pattern_dict.items():
- if v in l:
- l = l.replace(v, version_combo_dict[k])
- setup_content_new += l
+ for line in setup_content:
+ for k, v in pattern_dict.items():
+ if v in line:
+ line = line.replace(v, version_combo_dict[k])
+ setup_content_new += line
The variable name l
is ambiguous and should be renamed to line
for better readability.
Also applies to: 49-49
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
for l in setup_content: | |
for line in setup_content: | |
for k, v in pattern_dict.items(): | |
if v in line: | |
line = line.replace(v, version_combo_dict[k]) | |
setup_content_new += line |
Summary by CodeRabbit
New Features
Bug Fixes
Style
Tests