📰 Custom Issue
As #5623 has been merged, we're now in the position where we can slowly adopt incremental compliance of the ruff linter rules.
Our ruff configuration is defined in two files:
pyproject.toml: this contains the main ruff configuration for the linter (and formatter, when adopted) and permanent rule exclusions
.ruff.toml: this configuration extends the pyproject.toml and contains temporary rule exclusions
The goal of our ruff adoption is two-fold:
- Tackle individual rule categories defined in the
.ruff.toml on a piecemeal basis e.g., "F" or "ANN" etc
- Drop third-party packages replaced by
ruff.
Tackling Rules
We need to agree on a general way forward here.
However, essentially it will involve the following steps:
- Comment out a rule in the
.ruff.toml.
- Install
ruff in your development environment e.g., pip install ruff.
- Run
ruff e.g., ruff .
- Address the non-compliances:
- Consider using
ruff --fix . to auto-fix.
- Manually address the other non-compliances.
- Either:
- Remove the rule from
.ruff.toml, as we are now compliant.
- Replace the rule category with one or more exact rules that still require to be addressed e.g., replace
"F" (Pyflakes), which represents all pyflakes rules, with exact "Fxxx" rule instances that still require to be ignored.
Note that, rules can be ignored across all of iris by using the [tool.ruff.lint.ignore] in the pyproject.toml or the lint.ignore in the .ruff.toml.
Rules can also be ignored on a per file basis:
As a result of tackling the temporary rule exceptions in .ruff.toml we may uncover permanent rule exceptions that we want to adopt. These should be discussed, and if agreed, added and documented in the pyproject.toml.
Drop Third-Party Packages
The ruff linter and formatter replace the following packages, which we can now drop:
📰 Custom Issue
As #5623 has been merged, we're now in the position where we can slowly adopt incremental compliance of the ruff linter rules.
Our
ruffconfiguration is defined in two files:pyproject.toml: this contains the mainruffconfiguration for the linter (and formatter, when adopted) and permanent rule exclusions.ruff.toml: this configuration extends thepyproject.tomland contains temporary rule exclusionsThe goal of our
ruffadoption is two-fold:.ruff.tomlon a piecemeal basis e.g.,"F"or"ANN"etcruff.Tackling Rules
We need to agree on a general way forward here.
However, essentially it will involve the following steps:
.ruff.toml.ruffin your development environment e.g.,pip install ruff.ruffe.g.,ruff .ruff --fix .to auto-fix..ruff.toml, as we are now compliant."F"(Pyflakes), which represents allpyflakesrules, with exact"Fxxx"rule instances that still require to be ignored.Note that, rules can be ignored across all of
irisby using the[tool.ruff.lint.ignore]in thepyproject.tomlor thelint.ignorein the.ruff.toml.Rules can also be ignored on a per file basis:
pyproject.toml..ruff.toml.As a result of tackling the temporary rule exceptions in
.ruff.tomlwe may uncover permanent rule exceptions that we want to adopt. These should be discussed, and if agreed, added and documented in thepyproject.toml.Drop Third-Party Packages
The
rufflinter and formatter replace the following packages, which we can now drop:black(Replace black with ruff #5634)ruffformattertool.blacksection frompyproject.tomlpre-commithook from.pre-commit-config.yamlREADME.mdisort(Replace isort with ruff #5633)tool.isortsection frompyproject.tomlpre-commithook from.pre-commit-config.yaml"I"rule ignore from.ruff.tomlflake8(see Remove flake8 #6889).flake8configuration fileMANIFEST.inpre-commithook from.pre-commit-config.yaml