-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Apply preview ruff rules #12981
Apply preview ruff rules #12981
Conversation
966fa00
to
486b74b
Compare
It's a subjective preference, but I prefer that unused variables There's a few cases where this has been applied, but in lots of cases they are renamed to Pip maintainers may disagree though. |
I prefer |
Let's not do this -- if these are not ready to be stable rules in ruff, I don't think we need to go out of our way and eagerly enable things. |
The rules have not been enabled in Some of the rules should be part of the default in the next minor version, which I would expect to be released in a few months. But yes, it's possible to wait for that next version, no hurry. |
Agreed, let's not pre-emptively apply these rules. I'm not actually sure that we should automatically apply any new rules that ruff makes default in the future. We do have the option to explicitly switch them off, and there's some advantage to that (it reduces churn in our codebase). One of the points of automatic style rules is to reduce code churn, so if it's increasing the churn, that seems like it's a bad thing to me. We should apply the same logic (review any new rules and decide if we want them) to a change in ruff's defaults as we do to an explicit change to add a new rule. |
FWIW, my personal view is that this is precisely the sort of situation where I'd prefer to let the writer (and the reviewers) of the code judge for themselves what's the more readable option. So I'd rather we didn't try to make or enforce a "one size fits all" global rule. And following on from that, I'd argue that we should take an "if it isn't broken, don't fix it" approach to code covered by this rule, and leave it alone. |
F841 Local variable is assigned to but never used
E226 Missing whitespace around arithmetic operator
E262 Inline comment should start with `# `
C419 Unnecessary list comprehension
C420 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
486b74b
to
837ece4
Compare
I think we need to distinguish between formatters and linters, even if the following attempt for definitions shows overlaps:
In this case:
|
837ece4
to
d19be36
Compare
These issues appear when running
ruff check --preview
. The rules are not yet applied by default, but should become part of the default rulesets in future versions. The purpose of this PR is to make the code future-proof.I have not addressed code complexity issues:
There are multiple ways to address such issues;
Finally, note that I cannot silence a residual issue, caused by a ruff bug: