-
Notifications
You must be signed in to change notification settings - Fork 142
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
Migrate to Ruff, and extend black formatting #1638
Conversation
Related to #1620
.pre-commit-config.yaml
Outdated
- id: ruff | ||
args: [ --fix ] | ||
- id: ruff | ||
args: [--select, I, --fix] # only lint isort for Jupyter notebooks | ||
types_or: [ jupyter ] | ||
- id: ruff-format | ||
types_or: [ python, jupyter ] |
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.
With these settings, formatting and isort
is done on the codebase and notebooks (isort
counts as linting, so needs to be done separately for the notebooks).
Linting (i.e., adherence to styling that isn't already covered by the autoformatting) is only done on the codebase itself
[tool.ruff.format] | ||
# List of files to ignore formatting (ordered by ascending line count) | ||
exclude = [ | ||
"tests/test_mpirun.py", | ||
"parcels/tools/global_statics.py", | ||
"tests/test_tools.py", | ||
"parcels/gridset.py", | ||
"parcels/tools/timer.py", | ||
"parcels/application_kernels/TEOSseawaterdensity.py", | ||
"tests/test_particles.py", | ||
"parcels/application_kernels/interaction.py", | ||
"parcels/application_kernels/advectiondiffusion.py", | ||
"parcels/tools/statuscodes.py", | ||
"tests/test_data/create_testfields.py", | ||
"tests/test_diffusion.py", | ||
"parcels/tools/exampledata_utils.py", | ||
"parcels/tools/interpolation_utils.py", | ||
"parcels/interaction/neighborsearch/hashflat.py", | ||
"parcels/interaction/neighborsearch/hashspherical.py", | ||
"parcels/interaction/neighborsearch/basehash.py", | ||
"parcels/rng.py", | ||
"parcels/interaction/neighborsearch/base.py", | ||
"parcels/interaction/interactionkernel.py", | ||
"parcels/tools/converters.py", | ||
"parcels/application_kernels/advection.py", | ||
"parcels/particlefile.py", | ||
"parcels/compilation/codecompiler.py", | ||
"parcels/particle.py", | ||
"tests/test_interaction.py", | ||
"tests/test_particlefile.py", | ||
"parcels/application_kernels/EOSseawaterproperties.py", | ||
"tests/test_kernel_execution.py", | ||
"tests/test_particlesets.py", | ||
"parcels/particledata.py", | ||
"tests/test_kernel_language.py", | ||
"docs/conf.py", | ||
"parcels/grid.py", | ||
"tests/test_advection.py", | ||
"parcels/kernel.py", | ||
"parcels/fieldfilebuffer.py", | ||
"tests/test_fieldset_sampling.py", | ||
"parcels/compilation/codegenerator.py", | ||
"tests/test_grids.py", | ||
"parcels/particleset.py", | ||
"tests/test_fieldset.py", | ||
"parcels/fieldset.py", | ||
"parcels/field.py", | ||
] |
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.
See description in #1620 for more discussion on this
Linting is covered by pre-commit. os-short in matrix is legacy from 3 environment files
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.
Changes look good to me.
Note we will also need to update the list of GHA status checks that are required, in https://github.com/OceanParcels/parcels/settings/branch_protection_rules/315306.
Sounds good. I've now updated it to require pre-commit to pass. |
See here for a full list of rules supported by Ruff. The ruleset chosen is nearly identical to the one that was already in the codebase.