Skip to content

Change to default line width in ruff - #324

Merged
cbrnr merged 4 commits into
cbrnr:mainfrom
DimitriPapadopoulos:88
Aug 6, 2026
Merged

cbrnr merged 4 commits into
cbrnr:mainfrom
DimitriPapadopoulos:88

Conversation

@DimitriPapadopoulos

Copy link
Copy Markdown
Contributor

Use the default width of 88 characters instead of 92.

Fixes #320.

@DimitriPapadopoulos
DimitriPapadopoulos force-pushed the 88 branch 2 times, most recently from 6c0eff6 to 68187ef Compare August 5, 2026 19:09
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.
@cbrnr
cbrnr merged commit d18d20b into cbrnr:main Aug 6, 2026
8 checks passed
@cbrnr

cbrnr commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Thanks @DimitriPapadopoulos!

Comment thread pyproject.toml

[tool.ruff.lint]
extend-select = ["C4", "D", "FURB", "I", "PERF", "W", "UP"]
extend-select = ["C4", "D", "PERF", "W"]

@DimitriPapadopoulos DimitriPapadopoulos Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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, and YTT are fully covered (including preview rules), and I is covered except for I002, which needs the lint.isort.required-imports setting. No other group is fully covered.
[...]

  • Removed the RF102 check ("isort must be selected"). RF101 (B) and RF103 (UP) stay, because those groups are not fully default.

But then the defaults may be good enough for us.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

OK, I thought these were included by default? https://docs.astral.sh/ruff/default-rules/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

OK, I think the defaults should be fine, but feel free to add specific rules that you think are important.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I agree. Feel free to add them back in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use 88 characters line width

3 participants