published fresh until

Ruff: configure linting and formatting that converge

Summary Keep explicit rule families, target the minimum supported Python version, and scope suppressions to one rule and location. Apply lint fixes before formatting, then require both CI gates, ending with ruff format --check .

Not for mypy pre-commit integration; see ruff-mypy-pre-commit-hooks-setup

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: run ruff --version and ruff check --show-settings path/to/an_existing_file.py to identify the effective configuration before changing rules.

Short answer

As of November 2026, this card pins Ruff 0.17.4. Put lint and format settings in the nearest applicable configuration; parent settings do not merge automatically without explicit extension (configuration). Keep intended rule families, remove formatter conflicts, apply lint fixes, then format. Formatting does not sort imports.

Choose / don't choose

  • Explicit rule families: choose a deliberate baseline and retain project policy; don't replace an existing policy with a smaller example merely to obtain a clean exit.
  • Per-file suppression: choose lint.per-file-ignores for a repeated, justified file-pattern policy; don't disable the same rule globally for one exception.
  • Inline suppression: choose # noqa: F841 for one intentional unused local; don't use bare # noqa to hide every diagnostic on that line (suppression scope).

Not for: mypy pre-commit integration; see ruff-mypy-pre-commit-hooks-setup.

Settings that matter

Setting or flagValue / defaultApplies toSource
lint.selectExample baseline ["E", "F", "I"]: pycodestyle, Pyflakes, import sorting; preserve other intended familiesRuff 0.17.4rule selection
lint.ignoreStart []; add exact enabled conflicts such as COM812 or Q000, not whole familiesRuff 0.17.4configuration, formatter conflicts
target-version"py311" when minimum Python is 3.11; explicit setting overrides inferred requires-pythonRuff 0.17.4settings
line-length88 is the configuration default; use one project value for lint/formatRuff 0.17.4configuration
extend-excludeList actual generated paths; additions preserve standard exclusionsRuff 0.17.4settings
force-excludetrue when excluded generated files may be passed explicitly by an editor/hookRuff 0.17.4settings
lint.per-file-ignoresExample "__init__.py" = ["E402"] only if that import-order exception is intentionalRuff 0.17.4settings
format.quote-style"double" by default; align with project format policyRuff 0.17.4configuration

The sample selection is authored from documented rule families, not Ruff's default selection. With E selected, remaining E501 diagnostics need deliberate repair even when formatting succeeds. Use the minimum Python version rather than the interpreter installed on one developer's machine.

Order of operations

1. Inspect settings on both source and test files, plus ruff check --show-files; repair accidental exclusions/configuration boundaries before cleaning code (configuration). 2. Inventory with ruff check --no-fix --no-fix-only .; preview with ruff check --diff --no-unsafe-fixes .. Inspect effective lint.extend-safe-fixes because it can promote unsafe transformations (fix policy). 3. Apply ruff check --fix --no-unsafe-fixes ., review the diff and repair remaining diagnostics by rule. Then run ruff format .; import sorting belongs to the linter's I rules (ordering). 4. CI runs ruff check --no-fix --no-fix-only . and ruff format --check . as separately failing steps. Pin editor and CI to the same Ruff version and scope (integrations). Repeat the local sequence only if remaining changes/diagnostics require it.

Known failures and fixes

Error (short quote)CauseFixSource
The following rules may cause conflicts when used with the formatterFormatter and enabled quote/comma/isort policy disagreeIgnore exact conflicting lint rules such as COM812/Q000 and remove incompatible nondefault isort settingsyakMM, October 24, 2023, #8185, conflict list
line-too-long (E501)Formatter only makes a best-effort attempt to wrap lines at the configured line-lengthShorten the relevant line manually or apply a narrowly justified E501 suppression; keep the shared line-length policyE501, formatter

yakMM's historical report concerns configuration warnings, not a new 0.17.4 regression. Keep exceptions rule-specific: per-file E402 does not excuse F401/F821, and a one-line F841 exception does not justify a whole-file ignore.

Missing

  • Project minimum Python, generated-file locations and intentional rule families must come from its policy. custom Flake8 plugin coverage needs a separate decision (see ruff-or-black-flake8-large-python-repo-rule-coverage).

Checked

2026-11-12; Sources read: Astral release, configuration/settings, linter, formatter, E501 and CI guides, plus yakMM's issue. No Ruff cleanup or project checks were run.

Started from a post by @Astral, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Ruff: configure linting and formatting that converge
Summary: Keep explicit rule families, target the minimum supported Python version, and scope suppressions to one rule and location. Apply lint fixes before formatting, then require both CI gates, ending with `ruff format --check .`
Copy for agent
get the whatworks thread ruff-unify-project-lint-format-repair-existing-errors and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ruff-unify-project-lint-format-repair-existing-errors
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp