-
Notifications
You must be signed in to change notification settings - Fork 31
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 to pre-commit #819
Conversation
updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](pre-commit/pre-commit-hooks@v4.5.0...v4.6.0) - [github.com/psf/black: 24.3.0 → 24.4.0](psf/black@24.3.0...24.4.0)
updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](pre-commit/pre-commit-hooks@v4.5.0...v4.6.0) - [github.com/psf/black: 24.3.0 → 24.4.2](psf/black@24.3.0...24.4.2)
…mso into pre-commit-ci-update-config
for more information, see https://pre-commit.ci
ryckaert_connection_type = convert_opls_to_ryckaert( | ||
opls_connection_type | ||
) | ||
ryckaert_connection_type = convert_opls_to_ryckaert(opls_connection_type) |
Check notice
Code scanning / CodeQL
Unused local variable Note
ryckaert_connection_type = convert_opls_to_ryckaert( | ||
opls_connection_type | ||
) | ||
ryckaert_connection_type = convert_opls_to_ryckaert(opls_connection_type) |
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning
redefined
connection_lines = open(filename, "r").readlines()[ | ||
i + 2 : i + n_connections + 2 | ||
] | ||
connection_lines = open(filename, "r").readlines()[i + 2 : i + n_connections + 2] |
Check warning
Code scanning / CodeQL
File is not always closed Warning
Looks like the pre-commit has a lot of recommendations for changes. @daico007 I think we should look at some custom parsing, because notes like the |
If the only issue is the F401 errors in the See this in the documentation |
Yes that would be good. We may have to do that with a few of the different files this way because it's a bunch of files across the project. |
Reading the ruff documentation https://docs.astral.sh/ruff/linter/#error-suppression We can add |
The rest of the suggested changes seem pretty reasonable I think. What do you all think @CalCraven @daico007 ? |
I would say we should ignore things for the |
for more information, see https://pre-commit.ci
I think I got most of the errors fixed (even in the tests). There are some lingering ones about not using I think we should fix the bare excepts, I just don't know what the errors should be off the top of my head. We use |
forcefield_selection_with_paths[residue] = ( | ||
ff_names_path_iteration | ||
) | ||
read_xlm_iteration = minidom.parse(ff_names_path_iteration) # noqa: F841 |
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning
redefined
https://github.com/BrianPugh/python-template/blob/main/.pre-commit-config.yaml Going to link to a cookie-cutter version of a ruff linter, check out the pyproject.toml as well for some additional formatting stuff we could consider implementing, such as type checking and isort. |
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.
LGTM, just left one comment about how we want to handle automatic fixes on PRs.
.pre-commit-config.yaml
Outdated
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [--line-length=80] |
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.
Should we add the fix flag back in, so that easy formatting fixes are automatically made and comitted on PRs?
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.
yeah, sure! we can always turn it off later if it's become troublesome.
This is just a test PR to test the linting with Ruff, which is recommended by pydocstyle as a replacement and used by other big python package.