## Use case
`pr_ci.yaml` runs `flake8 datastore --count --show-source --statistics`
as the only PR gate that blocks merge. The configuration in `setup.cfg`
deliberately limits flake8 to critical errors (`E9, F63, F7, F82`).
flake8 here works, but it's a tool we install at PR time, run, and
discard. Migrating to ruff gets us:
- **Speed**: ruff 0.15 scans 43 `datastore/*.py` files in ~7 ms; flake8
6.x is multi-second on the same set
- **Single Rust binary** vs flake8's plugin ecosystem (no pinning
drama, no surprise behaviour change from a transitive plugin update)
- **Same rule codes** (`E9`, `F63`, `F7`, `F82`) — true drop-in, no
policy change implied
- **Standard `pyproject.toml` config** — consolidates with the
existing `[tool.pyright]` and `[tool.pytest.ini_options]` sections
- **Future capacity** to enable formatting / import-sorting via
`ruff format` if we ever want to (separate decision)
Most major Python projects (pandas, polars, FastAPI, Jupyter) have
already migrated. Recent chDB CI is the kind of place this lift is
both cheap and visible.
## Proposed solution
**Path 1 (drop-in parity, recommended)** — replace flake8 with ruff,
preserving exact behaviour:
```toml
# pyproject.toml — replaces setup.cfg [flake8]
[tool.ruff]
line-length = 120
target-version = "py39"
extend-exclude = [".tox", "build", "dist", ".eggs", "docs/conf.py", "datastore/tests"]
[tool.ruff.lint]
select = ["E9", "F63", "F7", "F82"]
ignore = ["F811"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
If this proposal gets a thumbs-up, I'll open the corresponding PR.
I have this on a local branch (
feat/lint-migrate-to-ruff) — onecommit on top of
main. Verified locally with ruff 0.15.12 on thecurrent codebase: scans 43
datastore/*.pyfiles (excludingtests/) in 6.7 ms, zero findings — exact behavioural parity withthe current flake8 setup.
If this proposal gets a thumbs-up, I'll open the corresponding PR.
Alternatives considered
broke, don't fix it" is real. The migration is justified by
speed + tooling consolidation, not by a current pain point.
ruff format(formatting check). Tempting— would replace currently-unenforced
blackinrequirements-dev.txt. But formatting policy is its own decision(existing diffs would all need formatting;
ruff format≠blackin a few edge cases). Suggest splitting into a follow-up.
E5(line-length),
W(warnings),I(isort),B(bugbear). Highersignal but unknown findings on the 1.5 MB existing codebase. Out
of scope for this proposal; this is pure drop-in.
Additional context
AGENTS.md§2.9explicitly defers this decision to maintainer discussion:
"Adding a new gate (e.g. enforcing
black, turning onmypy --strict, migrating flake8 → ruff) is a project-widedecision; open an issue and let maintainers weigh in." — this
issue is that step.
.pysource files change.setup.cfgbecomes empty after removing[flake8](no other toolreads it in this repo), so the proposed change deletes it. If you'd
prefer keeping an empty
setup.cfgfor future tools, easy to revert.AGENTS.md§2.9 / §6.3 / §11, the new PR-templatechecklist) reference flake8 by name. Once both this PR and the
AGENTS.md PR (#NNN) merge, a small follow-up commit can update the
doc references to ruff. Keeping the change small and targeted here.