After each stable Ruff release, the downstream notifier starts
`ruff-vscode`’s `release-prepare.yml` with the released version and
`auto-promote=true`. The extension merges its version bump after CI and
waits for approval before marketplace publication.
Merge
[ruff-vscode#1256](https://github.com/astral-sh/ruff-vscode/pull/1256)
first.
## Summary
Follow [uv’s release
workflow](https://github.com/astral-sh/uv/pull/19477) and [ty’s release
workflow](https://github.com/astral-sh/ty/pull/5014) by deriving the
GitHub release tag from the checked-out version. Ruff reads the
Cargo-style version from `crates/ruff/Cargo.toml` so prerelease tags
retain their existing format.
The documentation has stale configuration guidance and a few examples
that do not work as written. Clarify the prose and correct editor
configuration precedence, user-level configuration discovery, rule
descriptions, and the tutorial and configuration examples.
---------
Co-authored-by: Zanie Blue <zanie@openai.com>
Use the vendored runtime and generator instead of the registry dependency,
providing Unicode 17 names with Python-compatible matching. Update workspace
dependencies and tool configuration, add parser regressions, and document how
to update Unicode data when supporting a new Python version.
## Summary
Upgrade hyperfine to 2.0.0-alpha.2, which now includes support for
memory measurements (see output below).
Tested:
<details>
<summary>Formatter benchmark output</summary>
```text
Benchmark 1: ./target/release/ruff format ./fixture (2 runs)
mean ± σ min … max
Wall Time 12.8 ms ± 0.2 ms 12.7 ms … 12.9 ms
Memory 16.6 MiB ± 0.1 MiB 16.5 MiB … 16.6 MiB
Benchmark 2: black --no-cache ./fixture --safe (2 runs)
mean ± σ min … max
Wall Time 207.1 ms ± 4.8 ms 203.7 ms … 210.5 ms +1517.9% (16.2x slower)
Memory 37.3 MiB ± 0.1 MiB 37.2 MiB … 37.4 MiB +125.2% (2.3x more)
Benchmark 3: black --no-cache ./fixture --fast (2 runs)
mean ± σ min … max
Wall Time 226.6 ms ± 7.4 ms 221.4 ms … 231.9 ms +1670.7% (17.7x slower)
Memory 37.4 MiB ± 0.1 MiB 37.3 MiB … 37.5 MiB +126.2% (2.3x more)
Benchmark 4: black --no-cache ./fixture --safe --preview (2 runs)
mean ± σ min … max
Wall Time 250.1 ms ± 41.8 ms 220.6 ms … 279.6 ms +1854.3% (19.5x slower)
Memory 37.4 MiB ± 0.3 MiB 37.2 MiB … 37.6 MiB +126.0% (2.3x more)
Benchmark 5: black --no-cache ./fixture --fast --preview (2 runs)
mean ± σ min … max
Wall Time 186.2 ms ± 2.5 ms 184.5 ms … 188.0 ms +1355.1% (14.6x slower)
Memory 37.3 MiB ± 0.0 MiB 37.3 MiB … 37.3 MiB +125.2% (2.3x more)
Benchmark 6: autopep8 ./fixture --recursive --in-place (2 runs)
mean ± σ min … max
Wall Time 41.6 ms ± 0.7 ms 41.1 ms … 42.1 ms +225.2% (3.3x slower)
Memory 26.3 MiB ± 0.0 MiB 26.3 MiB … 26.3 MiB +58.8% (1.6x more)
Benchmark 7: yapf ./fixture --parallel --recursive --in-place (2 runs)
mean ± σ min … max
Wall Time 142.1 ms ± 4.8 ms 138.7 ms … 145.5 ms +1010.6% (11.1x slower)
Memory 29.1 MiB ± 0.3 MiB 28.9 MiB … 29.4 MiB +76.0% (1.8x more)
Benchmark 1: env RAYON_NUM_THREADS=1 ./target/release/ruff format ./fixture (2 runs)
mean ± σ min … max
Wall Time 12.7 ms ± 2.5 ms 10.9 ms … 14.4 ms
Memory 14.6 MiB ± 0.1 MiB 14.6 MiB … 14.7 MiB
Benchmark 2: black --no-cache ./fixture --workers=1 --safe (2 runs)
mean ± σ min … max
Wall Time 95.2 ms ± 3.2 ms 92.9 ms … 97.4 ms +650.6% (7.5x slower)
Memory 38.4 MiB ± 0.0 MiB 38.4 MiB … 38.4 MiB +162.6% (2.6x more)
Benchmark 3: black --no-cache ./fixture --workers=1 --fast (2 runs)
mean ± σ min … max
Wall Time 89.6 ms ± 2.8 ms 87.6 ms … 91.6 ms +606.5% (7.1x slower)
Memory 38.4 MiB ± 0.0 MiB 38.4 MiB … 38.4 MiB +162.7% (2.6x more)
Benchmark 4: black --no-cache ./fixture --workers=1 --safe --preview (2 runs)
mean ± σ min … max
Wall Time 94.7 ms ± 0.6 ms 94.3 ms … 95.2 ms +646.9% (7.5x slower)
Memory 38.5 MiB ± 0.1 MiB 38.5 MiB … 38.6 MiB +163.5% (2.6x more)
Benchmark 5: black --no-cache ./fixture --workers=1 --fast --preview (2 runs)
mean ± σ min … max
Wall Time 92.7 ms ± 0.6 ms 92.3 ms … 93.2 ms +631.4% (7.3x slower)
Memory 38.4 MiB ± 0.1 MiB 38.3 MiB … 38.4 MiB +162.5% (2.6x more)
Benchmark 6: autopep8 ./fixture --in-place --recursive --jobs=1 (2 runs)
mean ± σ min … max
Wall Time 43.5 ms ± 3.7 ms 40.9 ms … 46.1 ms +242.7% (3.4x slower)
Memory 26.5 MiB ± 0.1 MiB 26.4 MiB … 26.6 MiB +81.2% (1.8x more)
Benchmark 7: yapf ./fixture --recursive --in-place (2 runs)
mean ± σ min … max
Wall Time 56.8 ms ± 1.2 ms 55.9 ms … 57.6 ms +347.8% (4.5x slower)
Memory 27.3 MiB ± 0.1 MiB 27.2 MiB … 27.4 MiB +86.5% (1.9x more)
Benchmark 1: ./target/release/ruff format ./fixture --check (2 runs)
mean ± σ min … max
Wall Time 10.2 ms ± 0.3 ms 9.9 ms … 10.4 ms
Memory 16.9 MiB ± 0.1 MiB 16.8 MiB … 17.0 MiB
Benchmark 2: black --no-cache ./fixture --check --safe (2 runs)
mean ± σ min … max
Wall Time 193.8 ms ± 6.2 ms 189.5 ms … 198.2 ms +1806.9% (19.1x slower)
Memory 37.3 MiB ± 0.1 MiB 37.2 MiB … 37.4 MiB +120.8% (2.2x more)
Benchmark 3: black --no-cache ./fixture --check --fast (2 runs)
mean ± σ min … max
Wall Time 188.2 ms ± 1.9 ms 186.8 ms … 189.6 ms +1751.4% (18.5x slower)
Memory 37.3 MiB ± 0.1 MiB 37.3 MiB … 37.4 MiB +121.1% (2.2x more)
Benchmark 4: black --no-cache ./fixture --check --safe --preview (2 runs)
mean ± σ min … max
Wall Time 202.1 ms ± 6.3 ms 197.7 ms … 206.6 ms +1888.5% (19.9x slower)
Memory 37.2 MiB ± 0.0 MiB 37.2 MiB … 37.2 MiB +120.5% (2.2x more)
Benchmark 5: black --no-cache ./fixture --check --fast --preview (2 runs)
mean ± σ min … max
Wall Time 197.0 ms ± 20.1 ms 182.8 ms … 211.2 ms +1837.8% (19.4x slower)
Memory 37.2 MiB ± 0.0 MiB 37.2 MiB … 37.2 MiB +120.5% (2.2x more)
Benchmark 6: autopep8 ./fixture --recursive --diff (2 runs)
mean ± σ min … max
Wall Time 38.5 ms ± 0.1 ms 38.4 ms … 38.6 ms +278.4% (3.8x slower)
Memory 26.3 MiB ± 0.0 MiB 26.3 MiB … 26.4 MiB +56.0% (1.6x more)
Benchmark 7: yapf ./fixture --parallel --recursive --quiet (2 runs)
mean ± σ min … max
Wall Time 144.8 ms ± 7.4 ms 139.6 ms … 150.1 ms +1324.8% (14.2x slower)
Memory 29.0 MiB ± 0.2 MiB 28.9 MiB … 29.1 MiB +71.6% (1.7x more)
```
</details>
<details>
<summary>ty_benchmark (multi-threaded, then single-threaded)</summary>
```text
jinja
-----
Benchmark 1: ty (2 runs)
mean ± σ min … max
Wall Time 73.0 ms ± 5.6 ms 69.0 ms … 76.9 ms
Memory 100.1 MiB ± 0.1 MiB 100.0 MiB … 100.2 MiB
Warning: Ignoring non-zero exit code.
Benchmark 2: Pyrefly (2 runs)
mean ± σ min … max
Wall Time 118.3 ms ± 6.0 ms 114.0 ms … 122.5 ms +62.1% (1.6x slower)
Memory 130.9 MiB ± 0.2 MiB 130.8 MiB … 131.1 MiB +30.8% (1.3x more)
Warning: Ignoring non-zero exit code.
Benchmark 3: mypy (2 runs)
mean ± σ min … max
Wall Time 802.9 ms ± 8.0 ms 797.2 ms … 808.6 ms +1000.2% (11.0x slower)
Memory 143.4 MiB ± 0.1 MiB 143.3 MiB … 143.5 MiB +43.2% (1.4x more)
Warning: Ignoring non-zero exit code.
Benchmark 4: mypy (warm) (2 runs)
mean ± σ min … max
Wall Time 208.8 ms ± 5.6 ms 204.9 ms … 212.7 ms +186.1% (2.9x slower)
Memory 51.9 MiB ± 0.2 MiB 51.8 MiB … 52.0 MiB -48.2% (1.9x less)
Warning: Ignoring non-zero exit code.
Benchmark 5: Pyright (2 runs)
mean ± σ min … max
Wall Time 1198.8 ms ± 12.0 ms 1190.3 ms … 1207.3 ms +1542.8% (16.4x slower)
Memory 251.6 MiB ± 1.3 MiB 250.7 MiB … 252.5 MiB +151.3% (2.5x more)
Warning: Ignoring non-zero exit code.
jinja
-----
Benchmark 1: ty (2 runs)
mean ± σ min … max
Wall Time 226.1 ms ± 14.0 ms 216.2 ms … 236.0 ms
Memory 84.9 MiB ± 0.2 MiB 84.8 MiB … 85.0 MiB
Warning: Ignoring non-zero exit code.
Benchmark 2: Pyrefly (2 runs)
mean ± σ min … max
Wall Time 210.4 ms ± 6.9 ms 205.5 ms … 215.3 ms -7.0%
Memory 92.3 MiB ± 0.1 MiB 92.2 MiB … 92.4 MiB +8.8%
Warning: Ignoring non-zero exit code.
Benchmark 3: mypy (2 runs)
mean ± σ min … max
Wall Time 896.4 ms ± 88.8 ms 833.7 ms … 959.2 ms +296.4% (4.0x slower)
Memory 144.3 MiB ± 0.6 MiB 143.9 MiB … 144.7 MiB +70.0% (1.7x more)
Warning: Ignoring non-zero exit code.
Benchmark 4: mypy (warm) (2 runs)
mean ± σ min … max
Wall Time 213.0 ms ± 3.7 ms 210.4 ms … 215.6 ms -5.8%
Memory 51.7 MiB ± 0.1 MiB 51.6 MiB … 51.8 MiB -39.1% (1.6x less)
Warning: Ignoring non-zero exit code.
Benchmark 5: Pyright (2 runs)
mean ± σ min … max
Wall Time 981.9 ms ± 13.0 ms 972.6 ms … 991.1 ms +334.2% (4.3x slower)
Memory 315.4 MiB ± 5.9 MiB 311.2 MiB … 319.5 MiB +271.6% (3.7x more)
Warning: Ignoring non-zero exit code.
```
</details>
I also tested most of the other hyperfine invocations mentioned
somewhere in this repo.
## Summary
- Use the integer bit APIs stabilized in Rust 1.97 for packed node
indices, token capacity, rule iteration, and type-variable support sets.
- Use Cargo's warning policy in our native and WASM Clippy checks,
keeping warnings fatal without changing compiler flags and invalidating
the build cache. Update the contributing guides to match.
Preserves the Rust 1.97 MSRV. The warning policy change follows
https://github.com/astral-sh/uv/pull/22122.
this is primarily useful for testing the sts token exchange in a
non-load bearing environment ahead of merging #28484
, but may be useful for maintainers :)
`automations` environment has been created and `STS_API_URL` secret set
Release preparation still directs new crates to the local bootstrap
utility, which requires a crates.io owner token and tracks configured
crates in `.known-crates`. Use `astral-sh/crates-policies` as the source
of truth instead, matching
[astral-sh/uv#20449](https://github.com/astral-sh/uv/pull/20449).
`scripts/release.sh` now runs the shared workspace checker, the
contribution guide points to the central registration process, and the
duplicate setup utility and local crate list are removed.
Co-authored-by: Zanie Blue <contact@zanie.dev>
Summary
--
I've noticed that some issues seem to attract a lot of (likely
automated) duplicate PRs. #28102 is a
recent example that elicited four PRs in the five days it has been open.
I'm not sure if the changes
here will actually help, but I've tried to add both contributor- and
agent-facing documentation to
suggest checking for linked PRs before opening another one.
Test Plan
--
Future issues
Summary
--
This PR allows adding rules that only belong to categories and only have
names rather than requiring
a linter group and code.
The first non-empty commit uses `Rule::name` instead of
`Rule::noqa_code` throughout the linter tests, causing a huge number of
file renames without changes.
The second commit updates `FixTable` from a mapping of `SecondaryCode ->
(name, fix_count)` to
`DiagnosticId -> (Option<SecondaryCode>, fix_count)`. This doesn't
really change its usage but
involves minor diffs to a substantial number of lines. It also allows us
to drop some of the special
`hashbrown` handling and the `hashbrown` dependency in `ruff_linter`,
which is nice.
The third commit contains the bulk of the change, including the macro
changes needed to support
`map_codes` entries like that for the `pytest-fixture-autouse` rule in
the fourth commit:
```rust
() => rules::ruff::rules::PytestFixtureAutouse,
```
These changes are pretty mechanical overall, just handling cases where
the linter or noqa code could
be missing, which fortunately seemed pretty straightforward in every
case.
The fourth commit takes advantage of these changes to reinstate `RUF076`
as our first purely
`pedantic` rule. I'm happy to drop that if it's too controversial or
opens too many questions about
the previously-removed rule and its code, but I thought it was nice to
have a motivating example. We
moved this rule from `preview` to `removed` because it was too pedantic
for the `RUF` category, even
in preview, so it's exactly the kind of rule we can support now with the
categories.
Finally, the fifth commit updates the contributing docs to reflect that
linters and codes are
optional. This may need to be adjusted if we back out the `RUF076`
change.
Test Plan
--
Existing tests, plus a few new ones for `pytest-fixture-autouse`
Summary
--
This PR includes the contributor-facing documentation for the new
categories, as well as updated
rule acceptance guidelines built atop them.
I think we could also update our rule request template based on some of
these guidelines, but I'll save that for a follow-up once these are
solidified.
Test Plan
--
Future rule requests
---------
Co-authored-by: Micha Reiser <micha@reiser.io>
## Summary
This PR introduces clippy-style rule categories that can be used
alongside existing linter-based categories in preview. The categories
have a lower `specificity` than linter groups, meaning that `select =
UP` and `ignore = correctness` will not ignore `UP` correctness rules.
In general this leads to more rules being enabled than the alternative
we considered where categories and linter groups had equal precedence,
which makes it seem like a safer default. We can revisit this if it
proves to be unintuitive, or we can add a Cargo-style `priority` field
in the worst case.
I've tried to organize the commits such that this can be reviewed
commit-by-commit and could also be split into multiple PRs. The first
two commits update the `ViolationMetadata` macro to allow providing a
`category` argument and add such arguments for all rules. This part
could be a standalone change without exposing the categories to users
but still depends on reaching consensus on all rule categories. The
second pair of commits allows using the new categories as selectors
alongside existing selectors, including some precedence tests with other
selector types.
This mostly addresses #1774, but there are some sub-issues there to
resolve before closing the issue.
## Test Plan
New CLI tests and a new mdtest suite around rule precedence
## Summary
Add a locked `uv` workflow for running `prek` in CI and local
development.
This pins `prek` via a new `dev` PEP 735 dependency group, introduces a
committed `uv.lock` file, and updates CI to run `prek` through `uv run
--only-group dev --locked`. It also adds a frozen `uv-lock` pre-commit
hook to ensure future changes keep the lockfile in sync. Lastly, I
noticed that some pre-commit priority blocks did not match the comment
sections, so this does some opportunistic cleanup to move these around.
Atop #26461. Closes#26386.
## Test Plan
```bash
uv run --only-dev prek --all-files
```
## Summary
Publish Ruff's production Rust crates to crates.io as part of the
existing release workflow. This follows uv's setup: workspace
dependencies carry registry-compatible version pins, internal crates
receive generated READMEs and an explicit versioning policy, CI dry-runs
the full workspace publish, and release jobs publish missing crate
versions idempotently through crates.io trusted publishing.
The publishing set contains 32 packages: Ruff's CLI, WASM package,
server, linter, formatter, parser, and the internal Ruff component
crates required by them. It also includes `ty_module_resolver`,
`ty_site_packages`, and `ty_static`, because those three crates are part
of Ruff's normal dependency closure.
The publishing set deliberately excludes:
- Test-only crates: `mdtest`, `ruff_mdtest`,
`ruff_python_ast_integration_tests`, and
`ruff_python_trivia_integration_tests`.
- Benchmark and development crates: `ruff_benchmark` and `ruff_dev`.
- All remaining `ty_*` crates.
These packages retain `publish = false`, so bootstrap, version bumping,
README generation, CI dry-runs, and release publishing skip them through
Cargo metadata instead of a separate hard-coded allowlist.
The crates.io job is intentionally independent of release announcement,
so a crates.io outage cannot block the existing binary, PyPI, npm, or
GitHub release outputs. A bootstrap script reserves new crate names,
configures the release workflow as each crate's trusted publisher,
enables trusted-publishing-only releases, and records configured crates
for idempotent reruns.
The full workspace publish dry-run packages and verifies all 32 selected
crates.
Closes https://github.com/astral-sh/ruff/issues/43.
## Summary
This PR adds a `.agents/skills` directory to the repo, and adds three
skills to help agents work on ty more effectively:
- A skill to help them write better ty diagnostics
- A skill to help them minimize a single ecosystem change more
effectively
- A skill to help them analyze and summarise ecosystem reports more
effectively
The skills have been designed so that they will (hopefully) work well
whether a contributor is using Codex or Claude as their agent locally.
Codex should discover these skills automatically if you're working on
the repo; if you use Claude locally, you _should_ hopefully be prompted
by Claude to install the local skills due to them being listed as
recommended skills in `.claude/settings.json`.
## Test Plan
I ran `/review` locally with Codex, instructing it to be as nitpicky as
possible, until it could find no more issues with these skills.
Summary
--
* Drops the instructions for updating the ruff-lsp repo, which has been
archived
* Removes the minor release guidance for ruff-vscode, which we are now
updating each release
Summary
--
While working on #25233, I realized that my suggestion to group multiple
rules within the same
Markdown file using top-level headings ran afoul of a markdownlint
[rule] against having multiple
top-level headings in the same file. I was a bit worried about the size
of the resulting files if we
followed this suggestion anyway, so I think the best course of action is
to recommend directories
for each linter with a separate file per rule.
This PR updates our existing mdtests to this new structure and also
updates the recommendation in the
contributing docs.
Test Plan
--
Existing mdtests in new locations
[rule]:
https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md025---multiple-top-level-headings-in-the-same-document
Summary
--
This PR adds the `ruff_test` crate, a parallel crate to `ty_test` for
Ruff, to
enable the new mdtests in `ruff_linter`. I opted to follow the
`Db`-based
structure of `ty_test` to simplify the integration, but we end up
basically just
unpacking the files from the `Db` to call the `test_contents` function
from the
linter.
I also updated the section of the contributing guidelines on lint rule
testing to suggest using mdtests.
Test Plan
--
I copied over the S704 tests into a new mdtest. I selected this rule
because it had several separate fixture files that all used different
settings and each of the fixtures was relatively short. I had initially
reached for a more complicated rule (UP046), but this seemed less likely
to clutter the diff while still exercising most mdtest features.
---------
Co-authored-by: Micha Reiser <micha@reiser.io>
Summary
--
This is a follow-up to #21035 and #22732 to update the contribution
guide for
adding a new rule for the changes to the `violation_metadata` attribute
and also
to how we emit diagnostics.
Test Plan
--
Built and viewed the docs locally to make sure they render correctly
Summary
--
This PR adds a new section to CONTRIBUTING.md describing the expected
contents of the PR summary and test plan, using the ecosystem report,
and communicating the status of a PR.
This seemed like a pretty good place to insert this in the document, at
the end of the advice on preparing actual code changes, but I'm
certainly open to other suggestions about both the content and
placement.
Test Plan
--
Future PRs :)
---------
Co-authored-by: Micha Reiser <micha@reiser.io>
Summary
--
During the release today, I noticed that the changelog is finally too
long to
render at all on GitHub. This PR follows the same splitting procedure as
in
uv (astral-sh/uv#11510, astral-sh/uv#12099): first splitting the file
into one
per minor version, and then reversing the contents of each file to start
with
the breaking release (`changelogs/0.11.x.md` starts with 0.11.0 instead
of
0.11.13 as in the old changelog).
For the second part, I used
[`reverse-changelog.py`](https://github.com/astral-sh/uv/blob/main/scripts/reverse-changelog.py)
from the uv repo, so hopefully everything is correct. I spot-checked
0.7.0 at least.
First take on a contributing guide for `ty`. Lots of it is copied from
the existing Ruff contribution guide.
I've put this in Ruff repo, since I think a contributing guide belongs
where the code is. I also updated the Ruff contributing guide to link to
the `ty` one.
Once this is merged, we can also add a link from the `CONTRIBUTING.md`
in ty repo (which focuses on making contributions to things that are
actually in the ty repo), to this guide.
I also updated the pull request template to mention that it might be a
ty PR, and mention the `[ty]` PR title prefix.
Feel free to update/modify/merge this PR before I'm awake tomorrow.
---------
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: David Peter <mail@david-peter.de>
## Summary
Noticed there was a wrong tip on the Contributing guide, `cargo
benchmark lexer` wouldn't run any benches.
Probably a missed update on #9535
It may make sense to remove the `cargo benchmark` command from the guide
altogether, but up to the mantainers.
## Summary
When following the step-by-step instructions to run the benchmarks in
`CONTRIBUTING.md`, I encountered two errors:
**Error 1:**
`bash: hyperfine: command not found`
**Solution**: I updated the instructions to include the step of
installing the benchmark tool.
**Error 2:**
```shell
$ ./target/release/ruff ./crates/ruff_linter/resources/test/cpython/
error: `ruff <path>` has been removed. Use `ruff check <path>` instead.
```
**Solution**: I added `check`.
## Test Plan
I tested it by running the benchmark-related commands in a new workspace
within GitHub Codespaces.
## Summary
Occasionally, we receive bug reports that imports in `src` directories
aren't correctly detected. The root of the problem is that we default to
`src = ["."]`, so users have to set `src = ["src"]` explicitly. This PR
extends the default to cover _both_ of them: `src = [".", "src"]`.
Closes https://github.com/astral-sh/ruff/issues/12454.
## Test Plan
I replicated the structure described in
https://github.com/astral-sh/ruff/issues/12453, and verified that the
imports were considered sorted, but that adding `src = ["."]` showed an
error.