Repository navigation
Replace black, isort and flake8 with ruff - #637
Merged
Merged
Conversation
Style checks are now a single tool. The lint side is configured to be a faithful port of the old flake8 and isort setup, so this commit leaves the formatting of the codebase untouched and `ruff check` passes as-is; the reformat that `ruff format` wants is a separate change. The copyright header check moves from flake8-ets to ruff's CPY001 rule. The header text lives in ruff-copyright.toml as a regular expression, so the check covers the full wording and not just the copyright line. In place of the old strict-style workflow, which compared each file's end year against the current year, CPY001 holds every file to the configured year and a new check-copyright-year workflow holds that year to the current one. Two settings are worth calling out. `known-third-party` keeps the acme and attractors demo packages classified as they were under isort, which avoids a re-sort that would strand their "# Local imports." comments. The ruff dependency is upper-bounded because ruff changes formatting in minor releases, so an unpinned bump would reformat the codebase. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The separate file was only worth having if ruff could read the header text verbatim from it. It can't - CPY001 takes a regular expression from a config value either way - so the split bought nothing but an extra file. The current-year check greps pyproject.toml instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s style toolchain from black/isort/flake8 (plus flake8-ets) to ruff, including a ruff-based copyright header check and a lightweight workflow to keep the configured copyright year in sync.
Changes:
- Replace black/isort/flake8/flake8-ets with ruff in dependency groups, lockfile, and CI style workflow.
- Port lint/import-sorting/copyright-header configuration into
pyproject.tomlunder[tool.ruff]. - Replace the strict style workflow’s year check with a dedicated
check-copyright-yearworkflow.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Removes black/isort/flake8(+deps) and adds ruff to locked dev/style dependencies. |
pyproject.toml |
Drops black/isort config and introduces ruff configuration (rules, isort sections, copyright regex). |
CHANGES.rst |
Records the tooling migration in the changelog. |
AGENTS.md |
Updates contributor guidance to reference ruff instead of black/isort/flake8. |
.github/workflows/check-style.yml |
Switches CI style job to run ruff check. |
.github/workflows/check-copyright-year.yml |
Adds CI guard ensuring the configured copyright end year matches the current year. |
.github/workflows/check-style-strict.yml |
Removes the old strict workflow that relied on flake8-ets year checks. |
.flake8 |
Removes obsolete flake8 configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+53
to
58
| Style is enforced by ruff, provided by the `dev` group. Run both checks: | ||
|
|
||
| ```bash | ||
| uv run -m black --check --diff . | ||
| uv run -m isort --check --diff . | ||
| uv run -m flake8 . | ||
| uv run -m ruff check . | ||
| uv run -m ruff format --check --diff . | ||
| ``` |
Member
Author
There was a problem hiding this comment.
Not a concern - the reformat PR will be merged almost immediately after this one.
mdickinson
added a commit
that referenced
this pull request
Aug 7, 2026
Part of #636, and the follow-up to #637. Replaces #638, which was branched before #637's review changes; this one is built from scratch on current `main` so that it is exactly reproducible. ## How to reproduce this PR ```bash git checkout main # afa89dd git checkout -b ruff-reformat uv run --locked --only-group style -m ruff format . # commit 1 # add `ruff format --check --diff .` to check-style.yml # commit 2 ``` Two commits, ordered so that each one is green on its own: 1. **The reformat** — mechanical, the entire diff is the output of `ruff format .`. 133 files, +196/-435, `.py` files only. 2. **One line** adding `ruff format --check --diff` to the style workflow. Separated from the reformat so the check is only turned on once the codebase already satisfies it, rather than merging something red. ## What's actually in the diff Almost all of it is docstring normalization: ```diff -""" An application event. """ - +"""An application event.""" ``` That is the same change black wants at its current version, so it was coming either way — see #632. The remainder is lines rejoined at the length of 88 set in #637. ## Checks run locally, on each commit separately | | `ruff check` | `ruff format --check` | | --- | --- | --- | | Reformat commit | All checks passed | 215 files already formatted | | CI commit | All checks passed | 215 files already formatted | Also `uv run -m pytest` — 178 passed — and the `check-copyright-year` grep passes (2026/2026). *This PR was created with the assistance of an AI coding agent.* 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 7, 2026
mdickinson
added a commit
that referenced
this pull request
Aug 7, 2026
…ode (#644) Closes #643. Changelog entries in `CHANGES.rst` end with the number of the pull request that made the change, not the issue it closes. Nothing said so, and `AGENTS.md` had no changelog section at all, so this adds one. Behind that, Claude Code reads `CLAUDE.md`, not `AGENTS.md`, and this repository had neither — so nothing in `AGENTS.md` reached it, including the existing rule that a PR made with agent assistance has to say so. The new `CLAUDE.md` imports `AGENTS.md` with `@AGENTS.md` rather than repeating any of it, so there's no second copy to keep in sync. Also corrects the ruff entry, which cited issue #636 where #637 is the PR. I checked the other 257 `#N` references in `CHANGES.rst` against the GitHub API. Every trailing reference is a PR except one in 4.5.0 (`(#37)`), and the two mentions of `#417` are deliberate inline prose — "which caused the issue #417", with the PR number correctly in the trailing parens. So the convention is already near-universal; this just writes it down. I've left the 4.5.0 entry alone as long-released history. *This PR was created with the assistance of an AI coding agent.* --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
larsoner
added a commit
to larsoner/envisage
that referenced
this pull request
Aug 7, 2026
main replaced black, isort and flake8 with ruff (enthought#637) and reformatted with it (enthought#642) after this branch was cut, so the two files it touches were still formatted to black's 79 columns. Run ruff over them. main also documented the changelog conventions (enthought#644), so add the entries this PR owes: the fix under Fixes, and the plugin's first tests under Tests, beside the Pygments dependency (enthought#641) they turned up.
mdickinson
added a commit
that referenced
this pull request
Aug 7, 2026
Closes #653. Prepares the 8.0.1 release: * Retitle the in-development changelog section from `8.1.0` to `8.0.1`, and replace the `Released: YYYY-MM-DD` placeholder with today's date. * Add the overview, in the style used for earlier bugfix releases, and credit contributors since 8.0.0 under `Thanks to`. * Bump the version in `pyproject.toml` from 8.0.0 to 8.0.1, and refresh `uv.lock`, which pins the project's own version. (8.0.0 predated the lockfile, so this step is new since the last release.) Three PRs merged since the 8.0.0 tag had no changelog entry, so this adds them: the ruff reformat (#642), folded into the entry for the PR that configured ruff (#637), the `edm.yaml` move (#634), and the `pypa/gh-action-pypi-publish` bump (#633). #650 is deliberately left out, since it only edited the changelog. Happy to drop #633 and #634 if you'd rather keep the release notes to things a reader of them would act on. Pre-flight, beyond CI: `uv build` and `twine check --strict` both pass, and `uv sync --locked` confirms the refreshed lockfile. Diffing the 8.0.1 artifacts against the released 8.0.0 ones shows one difference that isn't explained by the changes since 8.0.0: the sdist now carries a `pyproject.toml.orig` beside a `pyproject.toml` that has been rewritten and stripped of its comments. That is `uv_build` working as designed — since uv 0.12.0 it always rewrites the sdist's `pyproject.toml` as TOML 1.0, so that older build frontends can consume it, and preserves the original alongside. The two parse to identical data. It arrived with #628, along with the switch to `uv_build`, and needs no action. *This PR was created with the assistance of an AI coding agent.* --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #636. This is the first of two PRs; the reformat that
ruff formatwants is #638, stacked on this one.
Style checks become a single tool. The lint side is configured as a faithful
port of the old flake8 and isort setup, so this PR leaves the formatting of
the codebase untouched and
ruff checkpasses as-is. That keeps the PRreviewable, and means nothing has to be merged red —
ruff format --checkisturned on in the follow-up, in the same change that makes it pass.
The copyright check
flake8-ets is replaced by ruff's
CPY001rule, configured by thenotice-rgxsetting inpyproject.toml.The aim is to keep flake8-ets's behaviour rather than improve on it, since
flake8-ets already matched the full nine-line header.
CPY001compares aregular expression, not a fixed string, so the header text is written with its
parentheses and periods escaped; a leading
\Aanchors it to the start of thefile, matching flake8-ets's
re.match; andmin-file-size = 1exempts emptyfiles, which flake8-ets special-cased.
Two differences are worth review:
2007-2026, so the start yearis now enforced too. flake8-ets accepted any start year — both
2020-2026and a bare
2026passed it — and checked only the end year. All 186non-empty source files already use
2007, so nothing changes today, but anew file must use the same range rather than its own.
CPY001reports one generic "Missing copyright notice at top of file" forany mismatch. That is less specific than flake8-ets, which separated a
wording failure (H101) from a wrong year (H102) and named the actual and
expected years. The
check-copyright-yearworkflow below covers the casethat message mattered most for — the year rolling over — but a hand-mangled
header now gets a vaguer diagnostic.
The nudge to update the year is preserved, in two halves that compose to the
same guarantee the strict-style workflow gave:
CPY001holds every source file to the year configured inpyproject.toml;check-copyright-yearworkflow holds that configured year to thecurrent year.
The second half is a plain
grepagainstdate --utc +%Y, so it needs noPython and no ruff. The old
check-style-strict.ymlis removed.Two settings worth calling out
known-third-party = ['acme', 'attractors']keeps the demo packagesclassified as isort had them. Without it ruff treats them as first-party and
re-sorts 11 files, stranding their
# Local imports.comments above the wrongimports. With it,
ruff checkreports zero violations on the tree as itstands.
The ruff dependency is upper-bounded to
~= 0.16.0. Ruff confines formattingchanges to minor releases, so an unpinned bump would silently reformat the
codebase — exactly what #632 is currently doing with black 26. Raising the
bound in future is a deliberate change that carries its own reformat.
Other notes
E203/E266/W503ignores are needed; those rules arepreview-only in ruff.
*/api.py: F401carries over asper-file-ignores..pyfiles.stylejob keeps its name, so branch protection needs no changes.this route. Bump black from 24.10.0 to 26.5.1 #632 is a Dependabot security update: there is an open
high-severity advisory against black covering
>= 24.3.0, < 26.3.1, and thepinned
black ~= 24.3resolves to 24.10.0, inside that range. Removingblack from
uv.lockaltogether resolves it without taking black 26 and thereformat it brings. If this PR stalls, Bump black from 24.10.0 to 26.5.1 #632 remains the fallback.
Checks run locally
uv run --locked --only-group style -m ruff check .— passesuv run -m pytest— 178 passedThis PR was created with the assistance of an AI coding agent.
🤖 Generated with Claude Code