Change to default line width in ruff - #324
Conversation
6c0eff6 to
68187ef
Compare
Use the default width of 88 characters instead of 92.
By default, ruff selects rules that are compatible with the use of a formatter. It will ignore rules such as E501.
|
Thanks @DimitriPapadopoulos! |
|
|
||
| [tool.ruff.lint] | ||
| extend-select = ["C4", "D", "FURB", "I", "PERF", "W", "UP"] | ||
| extend-select = ["C4", "D", "PERF", "W"] |
There was a problem hiding this comment.
@cbrnr Not 100 % sure FURB, I or UP should be removed. From scientific-python/cookie#843:
Ruff 0.16 turns on 413 rules without configuration. Compared the default set against the full rule index:
BLE,DTZ,FA,FLY,INT,PIE, andYTTare fully covered (including preview rules), and I is covered except forI002, which needs thelint.isort.required-importssetting. No other group is fully covered.
[...]
- Removed the
RF102check ("isort must be selected").RF101(B) andRF103(UP) stay, because those groups are not fully default.
But then the defaults may be good enough for us.
There was a problem hiding this comment.
OK, I thought these were included by default? https://docs.astral.sh/ruff/default-rules/
There was a problem hiding this comment.
Not all rules, but I guess the ruff authors made a sensible choice.
Nevertheless, I'd like to understand which rules in B and UP they left out, and why they left out I002 — it should be a no-op anyway without required-imports.
There was a problem hiding this comment.
OK, I think the defaults should be fine, but feel free to add specific rules that you think are important.
There was a problem hiding this comment.
Here's the B and UP rules that are not selected by default still:
🤖 AI text below 🤖
Checked against ruff 0.16.2 (--show-settings enabled list vs ruff rule --all).
B (flake8-bugbear): 43 rules, 29 on by default, 14 not.
Stable rules you only get by selecting B:
| Code | Rule |
|---|---|
| B007 | unused-loop-control-variable |
| B011 | assert-false |
| B024 | abstract-base-class-without-abstract-method |
| B027 | empty-method-without-abstract-decorator |
| B028 | no-explicit-stacklevel |
| B034 | re-sub-positional-args |
| B904 | raise-without-from-inside-except |
| B905 | zip-without-explicit-strict |
| B911 | batched-without-explicit-strict |
| B912 | map-without-explicit-strict |
Preview-only, so selecting B still does not turn them on: B043, B901, B903, B909.
UP (pyupgrade): 48 rules, 42 on by default, 6 not.
Stable gains: UP013 (convert-typed-dict-functional-to-class), UP015 (redundant-open-modes), UP042 (replace-str-enum).
Preview-only: UP051. Removed from ruff entirely: UP027 (0.8.0), UP038 (0.13.0).
There was a problem hiding this comment.
IMO, there are still good codes not enabled by bugbear, but pyupgrade is pretty well covered. Not enough that I'd drop UP, but not enough for me to recommend it as a dedicated check anymore, I think.
There was a problem hiding this comment.
I agree. Feel free to add them back in another PR.
Use the default width of 88 characters instead of 92.
Fixes #320.