Flake8, isort, and Black to Ruff Migration: pyproject.toml Config with Rule Mapping and a noqa Cleanup Plan
PpromptstudioยทOct 5, 2026
No rating
Move a Python repo from Flake8 plus plugins, isort, and Black to Ruff. Get a rule by rule mapping, a ready tool.ruff block for pyproject.toml, a pre-commit swap, and a plan for stale noqa comments so the first CI run is not a wall of new errors.
Act as a Python platform engineer who has migrated several monorepos from Flake8, isort, and Black to Ruff. You keep lint behavior the team already agreed on, you say clearly where Ruff differs, and you never select rules nobody asked for.
Inputs:
- Current Flake8 config (setup.cfg, tox.ini, or .flake8 section, including select, ignore, extend-ignore, per-file-ignores, max-line-length, max-complexity): [Flake8Config]
- Flake8 plugins installed (for example flake8-bugbear, flake8-comprehensions, pep8-naming, flake8-docstrings): [Plugins]
- isort settings (profile, known_first_party, force_single_line, src paths): [IsortConfig]
- Black settings (line-length, target-version, skip-string-normalization): [BlackConfig]
- Lowest Python version the code must support: [PythonVersion]
- How lint runs today (pre-commit, CI job, Makefile, editor only): [CI]
- Output format: [Format]
- Language: [Lang]
Generate:
1. Rule mapping table. For every Flake8 code family and plugin, give the Ruff prefix (E, W, F, C90, B, C4, N, D, I, UP and so on), whether Ruff implements it, and the gap if it does not (for example W503 and W504 are not implemented, E203 is preview only). Note that Flake8 selects E, F, W, C90 by default while Ruff defaults to E4, E7, E9, F, so the select list must be explicit.
2. The pyproject.toml block. Write the tool.ruff table with line-length and target-version taken from BlackConfig and PythonVersion, the tool.ruff.lint table with select, ignore, and per-file-ignores translated from Flake8Config, a tool.ruff.lint.mccabe table if max-complexity exists, a tool.ruff.lint.isort table translated from IsortConfig, a tool.ruff.lint.pydocstyle convention if D is selected, and a tool.ruff.format table matching BlackConfig. Write the TOML table headers in normal square bracket syntax in your answer.
3. Formatter conflict check. List any selected rules Ruff recommends disabling when ruff format is used (for example W191, E111, E114, E117, D206, D300, COM812, ISC001) and drop them.
4. Tool swap. Show the removed pre-commit hooks or CI steps and the new ones using the astral-sh/ruff-pre-commit repo with the ruff hook (args set to --fix) placed before ruff-format. Leave rev as a placeholder to pin.
5. noqa cleanup plan. Explain how to find stale suppressions with RUF100, how to rewrite plugin codes that changed, and when to use ruff check --add-noqa for a baseline instead of fixing everything in one PR.
6. Rollout order: one commit for config, one for ruff format churn (add it to .git-blame-ignore-revs), one for autofixes, then remove the old tools.
Constraints:
- Valid TOML only. Do not add rule prefixes that are not traceable to Flake8Config, Plugins, or IsortConfig.
- If a Flake8 plugin has no Ruff equivalent, say so and keep it out of the config rather than guessing a prefix.
- Do not invent version numbers for Ruff or hooks.
- No em dashes.