Skip to content

Conversation

@cclauss
Copy link
Contributor

@cclauss cclauss commented Feb 28, 2023

Ruff supports over 400 500 lint rules including flake8, isort, pylint, and pyupgrade and is written in Rust for speed.
Also added rules for pylint conventions and pylint errors.

@Pierre-Sassoulas
Copy link
Member

Who can take the decision to drop python 3.6 ? It's been EOL for a long time at this point.

@RonnyPfannschmidt
Copy link
Member

Yes we can

@cclauss
Copy link
Contributor Author

cclauss commented Feb 28, 2023

#567 drops py36

@ionelmc
Copy link
Member

ionelmc commented Feb 28, 2023

Ruff looks nice if it can replace the all the tools with a single config. Are there any downsides with ruff or anything that would need attention?

@cclauss
Copy link
Contributor Author

cclauss commented Feb 28, 2023

I have not seen downsides (except maybe it is not yet v1.0) and I have been using it broadly:
https://beta.ruff.rs/docs/#testimonials

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the fact that without fix it's not equivalent to having pyupgrade LGTM.

@ionelmc
Copy link
Member

ionelmc commented Mar 10, 2023

I've played a bit with ruff now, its isort support is incomplete (no support for default-section or src-paths at least). The old isort hook needs to be kept.

@cclauss
Copy link
Contributor Author

cclauss commented Mar 10, 2023

This cannot be achieved by using forced separate, known parties, known local folder and src?

If not then I can drop the I rules from this pull request and bring back isort.

Timothy Crosley, creator of isort:

Just switched my first project to Ruff. Only one downside so far: it's so fast I couldn't believe it was working till I intentionally introduced some errors.

.ruff.toml Outdated
"dist",
]
line-length = 140
select = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be extend-select instead?

Copy link
Contributor Author

@cclauss cclauss Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're wondering how to configure Ruff, here are some recommended guidelines:

  • Prefer select and ignore over extend-select and extend-ignore, to make your rule set explicit.

https://beta.ruff.rs/docs/configuration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well all I want is to not hardcode a ruleset (which select = [stuff] exactly is). I don't think any of those recommendations are worth considering blindly given the tool's age and popularity.

How about select = ["ALL"] and ignore whatever doesn't make sense for pytest-cov?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're wondering how to configure Ruff, here are some recommended guidelines:

  • Prefer select and ignore over extend-select and extend-ignore, to make your rule set explicit.
  • Use ALL with discretion. Enabling ALL will implicitly enable new rules whenever you upgrade.
  • Start with a small set of rules (select = ["E", "F"]) and add a category at-a-time. For example, you might consider expanding to select = ["E", "F", "B"] to enable the popular flake8-bugbear extension.
  • By default, Ruff's autofix is aggressive. If you find that it's too aggressive for your liking, consider turning off autofix for specific rules or categories (see FAQ).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are way too many categories to enable manually. I'd expect that there are more good checks than broken or bad ones.

I noticed it's aggressive ... or rather destructive. That's why I think --show-fixes is a must. I think avoiding --fix actually adds more friction (too much back and forth for avoidable manual stuff).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so I've played with it a bit more.... now I am not really sure what the best way... eg: these are either invalid checks or would be a pain to sort out, or not even worth fixing:

ignore = [
    "D", # pydocstyle
    "ANN", # flake8-annotations
    "ARG", # flake8-unused-arguments
    "BLE", # flake8-blind-except
    "C90", # mccabe
    "EM", # flake8-errmsg
    "FBT", # flake8-boolean-trap
    "INP", # flake8-no-pep420
    "PLR", # Pylint Refactor
    "PLW", # Pylint Warning
    "Q", # flake8-quotes
    "RET", # flake8-return
    "SIM102", # flake8-simplify collapsible-if
    "SIM105", # flake8-simplify use-contextlib-suppress
    "SLF", # flake8-self
    "T20", # flake8-print
    "S101", # flake8-bandit assert
    "S102", # flake8-bandit exec
    "S110", # flake8-bandit try-except-pass
    "TRY", # tryceratops
]

Now considering that rsync features are being dropped in xdist ... a lot of bulk using that in pytest-cov becomes unnecessary, if it isn't already as some people are suggesting pytest-cov is not necessary for getting xdist support...

I guess select with a few is fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... How should we proceed? Given your explorations and your knowledge of the codebase, do you want to open a new PR that cherry-picks from this one? I have no trouble closing this with unmerged commits. Or should I press on?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also recommend the C4 checks as they are popular, increase performance, and have autofixes enabled for all rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there somewhere proof that C4 mods increase performance?

@cclauss
Copy link
Contributor Author

cclauss commented Mar 20, 2023

As the Ruff docs say, select=ALL is a bad idea. Closing.

@cclauss cclauss closed this Mar 20, 2023
@cclauss cclauss deleted the ruff branch March 20, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants