Add Ruff linting and autoformatting#562
Merged
rafmudaf merged 13 commits intoNatLabRockies:developfrom Feb 6, 2023
Merged
Conversation
F are pyflakes E are pycodestyle https://github.com/charliermarsh/ruff#pyflakes-f Note: line length errors are not excluded here
Max line length setting is 100
Here, it’s only adding a blank line at the end
757d1e3 to
f74574a
Compare
Collaborator
Author
|
@RHammond2 Could you please look over this pull request and especially the |
Import formatting. Ruff is not yet at parity with isort, but it is pretty close.
Collaborator
|
@rafmudaf I'm adding some comments for settings we should add or think about adding in the future. Otherwise, I think this is a good setup to get us working towards replacing our current setup, especially while it's still in active development for expanding and refining its capabilities.
|
Collaborator
Author
|
892c553 to
c5edb47
Compare
78c3d73 to
2785f1b
Compare
RHammond2
approved these changes
Feb 6, 2023
Use pre-commit with Actions Also update the developer dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature or improvement description
This pull request adds configuration for Ruff as a linker and in some cases autoformatter. The decision to use Ruff came about after evaluating a few others tools. The decision and key priorities are described in a discussion, #561.
The basic configuration is in place here and most errors have been fixed. A few errors are ignored and should be addressed in the future. These are listed in the pyproject.toml ruff configuration under the header "# FIXME"; see https://github.com/rafmudaf/floris/blob/ruff/pyproject.toml#L124.
This pull request causes quite a few changes throughout the project, but they are all stylistic and no algorithmic changes are included.
Usage
Ruff is command line tool and also has integrations into other development tools like IDE's and git-precommit. As a command line utility, it is run with a form of the following command:
ruff . --fixThis example applies all of the settings in
pyproject.tomlto all Python files in.recursively and also fixes the errors that it is able to.See the Ruff documentation for integrations into other tools.
GitHub Integration
Ruff is included in the
Automated tests & code coverageworkflow in GitHub Actions. It automatically runs Ruff from the mainfloris/directory and the output format is specific to GitHub. A failing check will send the typical email for CI failure, and the specific failures will be listing in the GitHub Actions window:Related issue, if one exists
No issue, but see this discussion: #561.
Impacted areas of the software
Most files are changed to conform to the Ruff rules.