Skip to content
Latchkey

ruff line-length: Set the Max Line Length

line-length sets the column at which the formatter wraps and at which the E501 line-too-long rule triggers; the default is 88.

One setting drives both the formatter and the E501 lint. Keeping them in sync avoids the classic format-then-lint loop.

What it does

line-length, set under [tool.ruff], is the target line width for ruff format and the threshold for the E501 line-too-long lint rule. The default is 88, matching Black. Both the formatter and the linter read the same value.

Common usage

pyproject.toml
[tool.ruff]
line-length = 100

Behavior

ItemWhat it does
line-lengthWrap width for format and threshold for E501
--line-length <n>Override on the command line
default 88Black-compatible default
E501Line-too-long rule that uses this value

In CI

Because line-length feeds both tools, set it once in pyproject.toml. If you raise it, the formatter stops wrapping early and E501 stops firing on those lines, keeping ruff format and ruff check consistent.

Common errors in CI

E501 violations on lines the formatter just produced usually mean the lint and formatter line-length disagree, which happens when one is overridden on the command line and not the other. Note the formatter does not force-wrap some constructs (long strings, URLs), so E501 can still fire after formatting; suppress those with noqa or by enabling specific rules rather than lowering the limit.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →