Skip to content

Increase max allowed value of line-length setting#24962

Merged
MichaReiser merged 7 commits into
astral-sh:mainfrom
EkriirkE:hotfix/Extend-Maximum-Line-Length
May 5, 2026
Merged

Increase max allowed value of line-length setting#24962
MichaReiser merged 7 commits into
astral-sh:mainfrom
EkriirkE:hotfix/Extend-Maximum-Line-Length

Conversation

@EkriirkE
Copy link
Copy Markdown
Contributor

@EkriirkE EkriirkE commented May 1, 2026

Summary

This moves the arbitrary line-length upper limit of 320 to the declared u16 type max of 65535, better allowing coders who have editors capable of line-wrapping to denote when they want lines to be forcibly broken up with trailing commas where applicable.

Test Plan

Compiled, and run against scripts reformatted by the 320 limit. It correctly flattened the previously exploded lists and functions when the trailing comma was removed.

Applicable issues:
Closes #24547
#8106

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented May 4, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Copy Markdown
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

I'm fine with this change in principle because I don't see a strong argument why we shoud allow 320 but not 360.

Having said that, I can't recommend using the formatter with very large line length values because it will start flattening expressions. For example, it will format comprehensions on a single line if it fits into the configured line length. A comprehension longer than 320 characters is probably very unreadable at that point.

We'll also need to update https://github.com/astral-sh/ruff/blob/573796806d74267720b8b931174bcfdb3c0e32a1/crates/ruff_workspace/src/options.rs#L442

Comment thread crates/ruff_linter/src/line_width.rs Outdated
Comment thread crates/ruff_linter/src/line_width.rs Outdated
@MichaReiser MichaReiser added the configuration Related to settings and configuration label May 5, 2026
@MichaReiser MichaReiser changed the title Change the random line limit of 320 to the maximum u16 65535 Increase max value of line-length setting May 5, 2026
@MichaReiser MichaReiser changed the title Increase max value of line-length setting Increase max value of line-length setting May 5, 2026
EkriirkE and others added 3 commits May 5, 2026 08:39
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Micha Reiser <micha@reiser.io>
@EkriirkE
Copy link
Copy Markdown
Contributor Author

EkriirkE commented May 5, 2026

Honestly this is my first real exposure to rust so I didn't know about the possibility of your change recs. Thanks!

I'm fine with this change in principle because I don't see a strong argument why we shoud allow 320 but not 360.

Having said that, I can't recommend using the formatter with very large line length values because it will start flattening expressions. For example, it will format comprehensions on a single line if it fits into the configured line length. A comprehension longer than 320 characters is probably very unreadable at that point.

Just like the ability to set your line lengths at all - leave it up to the coder's discretion :) They should already be aware of the effect of the setting, and understand how to choose when to prevent roll ups (nofmt/comment inside the comprehension, or no trailing comma for list/dict/&c). Anyone who's adjusted this setting already should have experienced the effects, regardless of the current ceiling.

We'll also need to update https://github.com/astral-sh/ruff/blob/573796806d74267720b8b931174bcfdb3c0e32a1/crates/ruff_workspace/src/options.rs#L442

Oops, got 'em! Thanks

@EkriirkE EkriirkE requested a review from MichaReiser May 5, 2026 11:58
Comment thread crates/ruff_workspace/src/options.rs Outdated
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thank you

@MichaReiser MichaReiser enabled auto-merge (squash) May 5, 2026 13:55
@MichaReiser MichaReiser changed the title Increase max value of line-length setting Increase max allowed value of line-length setting May 5, 2026
@MichaReiser MichaReiser merged commit ea6be89 into astral-sh:main May 5, 2026
43 checks passed
carljm added a commit that referenced this pull request May 6, 2026
* main: (63 commits)
  Update uraimo/run-on-arch-action action to v3.1.0 (#25011)
  Update dependency astral-sh/uv to v0.11.10 (#25002)
  Update prek dependencies (#25003)
  Update taiki-e/install-action action to v2.75.25 (#25007)
  Update Rust crate mimalloc to v0.1.50 (#25006)
  Update Rust crate libc to v0.2.186 (#25005)
  Update maturin to v1.13.1 (#25009)
  Update CodSpeedHQ/action action to v4.15.0 (#25008)
  Update Rust crate jiff to v0.2.24 (#25004)
  Increase max value of `line-length` setting (#24962)
  [ty] Fix the Pyodide assets deployment in the ty playground. (#24994)
  [ty] Selectively promote a union of homogeneous fixed-length tuples to a single variadic tuple. (#24705)
  [ty] Cache results in desperate module resolution (#24977)
  [ty] implement proper handling of recursive types in `CycleDetector` (#24773)
  [ty] Skip parameter accumulation for object variadics (#24976)
  Add missing rust related files when detecting changes in CI (#24971)
  [ty] Expand support for narrowing within walruses (#24968)
  [ty] Fix missing visitor guard in `Callable` branch (#24964)
  [ty] Allow reference finding in stringified annotations (#24956)
  [ty] Unpack Union of TypedDict in various sites (#24958)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Related to settings and configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

line-length directive should not be bounded

3 participants