-
Notifications
You must be signed in to change notification settings - Fork 1
ruff related fixes #181
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
ruff related fixes #181
Conversation
Warning Rate Limit Exceeded@jan-janssen has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 39 seconds before requesting another review. 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. WalkthroughThis update primarily focuses on refining and organizing the structuretoolkit package by enhancing the accessibility and clarity of its public entities. Key changes include updating 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 (
|
|
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: 6
Out of diff range and nitpick comments (4)
tests/test_dscribe.py (1)
Line range hint
11-11
: Remove unused importdscribe
.- import dscribe
tests/test_pyxtal.py (1)
Line range hint
7-7
: Remove unused importpyxtal
.- import pyxtal
tests/test_symmetry.py (2)
Line range hint
12-12
: Remove unused importpyscal
.- import pyscal
Line range hint
20-20
: Remove unused importspglib
.- import spglib
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (18)
- .ci_support/release.py (3 hunks)
- setup.py (1 hunks)
- structuretoolkit/init.py (1 hunks)
- structuretoolkit/analyse/init.py (1 hunks)
- structuretoolkit/build/init.py (1 hunks)
- structuretoolkit/build/aimsgb.py (1 hunks)
- structuretoolkit/build/compound.py (1 hunks)
- structuretoolkit/build/random.py (2 hunks)
- structuretoolkit/build/sqs.py (2 hunks)
- structuretoolkit/build/surface.py (3 hunks)
- structuretoolkit/common/init.py (1 hunks)
- structuretoolkit/common/helper.py (1 hunks)
- tests/test_dscribe.py (1 hunks)
- tests/test_pymatgen.py (7 hunks)
- tests/test_pyxtal.py (1 hunks)
- tests/test_snap.py (7 hunks)
- tests/test_symmetry.py (2 hunks)
- tests/test_visualize.py (1 hunks)
Files not summarized due to errors (1)
- tests/test_snap.py: Error: Message exceeds token limit
Files skipped from review due to trivial changes (6)
- setup.py
- structuretoolkit/build/init.py
- structuretoolkit/build/aimsgb.py
- structuretoolkit/build/surface.py
- structuretoolkit/common/init.py
- structuretoolkit/common/helper.py
Additional Context Used
Ruff (9)
.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
structuretoolkit/build/random.py (1)
11-11: Do not assign a
lambda
expression, use adef
tests/test_dscribe.py (1)
11-11:
dscribe
imported but unused; consider usingimportlib.util.find_spec
to test for availabilitytests/test_pyxtal.py (1)
7-7:
pyxtal
imported but unused; consider usingimportlib.util.find_spec
to test for availabilitytests/test_symmetry.py (2)
12-12:
pyscal
imported but unused; consider usingimportlib.util.find_spec
to test for availability
20-20:
spglib
imported but unused; consider usingimportlib.util.find_spec
to test for availability
Additional comments not posted (21)
tests/test_dscribe.py (1)
28-28
: LGTM! The updated tolerance value in the assertion improves precision.tests/test_visualize.py (1)
27-27
: LGTM! The changes improve the readability and clarity of the assertion statement.tests/test_pyxtal.py (1)
31-37
: LGTM! The changes improve the readability and clarity of thewith
statement.structuretoolkit/__init__.py (1)
80-135
: LGTM! The expanded__all__
list improves the module's usability by explicitly exporting more entities.structuretoolkit/build/sqs.py (2)
123-123
: Ensure that thesqs_optimize
import is necessary and used correctly.Verification successful
The
sqs_optimize
function is indeed used in thestructuretoolkit/build/sqs.py
file. The import statement and its usage in thesqs_structures
function appear to be correct.
structuretoolkit/build/sqs.py: from sqsgenerator import sqs_optimize
structuretoolkit/build/sqs.py: results, timings = sqs_optimize(
The changes related to the import and usage of
sqs_optimize
are valid.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `sqs_optimize` in the codebase. # Test: Search for the function usage. Expect: Only occurances of the new import. rg --type python $'sqs_optimize'Length of output: 62
Script:
#!/bin/bash # Description: Verify the usage of `sqs_optimize` in the codebase. # Test: Search for the function usage. Expect: Only occurrences of the new import. rg 'sqs_optimize' --glob '*.py'Length of output: 170
159-159
: Ensure that the additional statistics returned are correctly handled in the calling code.structuretoolkit/build/compound.py (1)
31-38
: The formatting changes improve readability. Ensure consistency across the codebase.structuretoolkit/analyse/__init__.py (1)
33-58
: The__all__
list expansion improves module usability. Ensure all listed entities are correctly defined and imported.tests/test_pymatgen.py (6)
60-62
: The formatting changes improve readability. Ensure consistency across the codebase.
87-90
: The formatting changes improve readability. Ensure consistency across the codebase.
129-129
: The formatting changes improve readability. Ensure consistency across the codebase.
138-138
: The formatting changes improve readability. Ensure consistency across the codebase.
151-151
: The formatting changes improve readability. Ensure consistency across the codebase.
195-195
: The formatting changes improve readability. Ensure consistency across the codebase.tests/test_symmetry.py (2)
158-158
: Consistent string formatting.
177-177
: Consistent string formatting.tests/test_snap.py (5)
9-9
: Necessary import for the new test case.
22-54
: LGTM! The array definition is clear and necessary for the test cases.
57-554
: LGTM! The array definition is clear and necessary for the test cases.
574-575
: Necessary attributes for the SNAP descriptor calculations.
608-608
: LGTM! The new test case is well-defined and necessary for validating the_get_lammps_compatible_cell
function.
@@ -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 for clarity.
- for l in setup_content:
+ for line in setup_content:
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: |
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 for clarity.
- for l in env_content:
+ for line in env_content:
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 env_content: | |
for line in env_content: |
@@ -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 for clarity.
- for l in setup_content:
+ for line in setup_content:
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: |
@@ -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: | |||
for k, v in pattern_dict.items(): | |||
if v in l: | |||
l = l.replace(v, version_combo_dict[k]) |
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 for clarity.
- for l in setup_content:
+ for line in setup_content:
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.
l = l.replace(v, version_combo_dict[k]) | |
line = line.replace(v, version_combo_dict[k]) |
structuretoolkit/build/random.py
Outdated
@@ -69,7 +69,7 @@ def generate(group): | |||
s.from_random( | |||
dim=dim, group=group, species=species, numIons=num_ions, **kwargs | |||
) | |||
except Comp_CompatibilityError as e: | |||
except Comp_CompatibilityError: |
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.
Avoid using lambda
for defining functions.
- tqdm = lambda x: x
+ def tqdm(x):
+ return x
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.
except Comp_CompatibilityError: | |
except Comp_CompatibilityError: | |
def tqdm(x): | |
return x |
structuretoolkit/build/random.py
Outdated
"symmetry": g, | ||
"repeat": i | ||
}) | ||
structures.append({"atoms": s, "symmetry": g, "repeat": i}) |
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.
Consider breaking down the warning message for better readability.
- warnings.warn(f'Groups [{", ".join(map(str,failed_groups))}] could not be generated with stoichiometry {stoich}!')
+ warnings.warn(
+ f'Groups [{", ".join(map(str, failed_groups))}] could not be generated with stoichiometry {stoich}!'
+ )
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.
structures.append({"atoms": s, "symmetry": g, "repeat": i}) | |
structures.append({"atoms": s, "symmetry": g, "repeat": i}) | |
warnings.warn( | |
f'Groups [{", ".join(map(str, failed_groups))}] could not be generated with stoichiometry {stoich}!' | |
) |
Summary by CodeRabbit
New Features
Bug Fixes
generate
function.Refactor
Style
Tests