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

ruff: incremental adoption #5625

Open
9 of 13 tasks
bjlittle opened this issue Dec 11, 2023 · 4 comments
Open
9 of 13 tasks

ruff: incremental adoption #5625

bjlittle opened this issue Dec 11, 2023 · 4 comments

Comments

@bjlittle
Copy link
Member

bjlittle commented Dec 11, 2023

📰 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:

  1. Tackle individual rule categories defined in the .ruff.toml on a piecemeal basis e.g., "F" or "ANN" etc
  2. 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:

  1. Comment out a rule in the .ruff.toml.
  2. Install ruff in your development environment e.g., pip install ruff.
  3. Run ruff e.g., ruff .
  4. Address the non-compliances:
    • Consider using ruff --fix . to auto-fix.
    • Manually address the other non-compliances.
  5. 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:

  • black (Replace black with ruff #5634)
    • Adopt ruff formatter
    • Remove tool.black section from pyproject.toml
    • Remove pre-commit hook from .pre-commit-config.yaml
    • Remove badge from the README.md
  • isort (Replace isort with ruff #5633)
    • Remove tool.isort section from pyproject.toml
    • Remove pre-commit hook from .pre-commit-config.yaml
    • Remove "I" rule ignore from .ruff.toml
  • flake8
    • Remove .flake8 configuration file
    • Update MANIFEST.in
    • Remove pre-commit hook from .pre-commit-config.yaml
@tkknight
Copy link
Contributor

numpydoc adoption tick list #4721 will address the pydocstyle (D) section in

iris/.ruff.toml

Lines 28 to 30 in c11d8bb

# pydocstyle (D)
# https://docs.astral.sh/ruff/rules/#pydocstyle-d
"D",

@trexfeathers
Copy link
Contributor

We need to agree on a general way forward here.

See #5612

@tkknight
Copy link
Contributor

tkknight commented Dec 17, 2023

Now #5636 is merged there is now a list of rules that are in the ignore section explicitly can now be addressed one by one in separate PR's.

Rules look here here https://docs.astral.sh/ruff/rules/#pydocstyle-d

@tkknight tkknight removed their assignment Feb 11, 2024
@tkknight
Copy link
Contributor

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

No branches or pull requests

3 participants