Skip to content
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

Merged
merged 3 commits into from
Aug 6, 2024
Merged

Migrate to Ruff, and extend black formatting #1638

merged 3 commits into from
Aug 6, 2024

Conversation

VeckoTheGecko
Copy link
Contributor

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.

Comment on lines 15 to 21
- 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 ]
Copy link
Contributor Author

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

Comment on lines +104 to 151
[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",
]
Copy link
Contributor Author

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
Copy link
Member

@erikvansebille erikvansebille left a 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.

@VeckoTheGecko VeckoTheGecko merged commit 83c6687 into master Aug 6, 2024
8 checks passed
@VeckoTheGecko VeckoTheGecko deleted the v/ruff branch August 6, 2024 07:51
@VeckoTheGecko
Copy link
Contributor Author

update the list of GHA status checks

Sounds good. I've now updated it to require pre-commit to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Migrate to ruff tooling for Python linting and formatting
2 participants