Commit Graph
547 Commits
Author SHA1 Message Date
Brent Westbrook 3e1f636451 Bump 0.15.21 (#26676) 2026-07-09 15:42:27 -04:00
Avasam 427138fee8 Add "How does Ruff's import sorting compare to isort?" link to README (#26530)
## Summary

Noticed a small inconsistency where the doc exists, but is only linked
to for Flake8 and Black, not isort.

## Test Plan

Look at the file preview and click the link

https://github.com/Avasam/ruff/blob/a42f1cd4b999a36081d371df43334c3204525171/README.md
2026-07-03 14:02:54 -04:00
Shaan Majid c5ee52a357 chore: lock rooster release dependency (#26509)
## Summary

Adds `rooster` to a new `release` dependency group, locks its full
dependency tree via `uv.lock`, and updates the release script to use the
locked installation for deterministic transitive dependency resolution.

Discussed in
https://github.com/astral-sh/ruff/pull/26463#discussion_r3504248600;
mirrored from astral-sh/uv#19923

## Test Plan

- `uv lock --check`
- `./scripts/release.sh` in a temporary worktree
2026-07-02 01:27:26 -07:00
Shaan Majid c360a05e9a chore: run prek from a locked uv dev group (#26463)
## 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
```
2026-07-01 01:09:42 -07:00
Samuel RigaudandSamuel Rigaud d78b3d5f32 Fix typos (#26443)
FIix even more typos

Co-authored-by: Samuel Rigaud <rigaud@gmail.com>
2026-06-28 23:23:37 +01:00
Charlie Marsh 08e9c847cf [ty] Refresh benchmark snapshots (#26422)
## Summary

Regenerate the ty benchmark snapshots against the current ty commit and
latest version of each tool:

- ty: `ruff/0.15.20+28 (1d2041ca1 2026-06-26)`
- Pyrefly: `1.1.1`
- Pyright: `1.1.411`
- mypy: `2.1.0`
2026-06-26 19:23:05 -04:00
Alex Waygood eb426d8b67 Bump docstring-adder pin (#26403) 2026-06-26 11:53:22 +00:00
Brent Westbrook f82a36b6ba Bump 0.15.20 (#26376) 2026-06-25 10:00:55 -07:00
Charlie Marsh d1dda84a42 [ty] Reject undeclared protocol instance attributes (#26336)
## Summary

Protocol instance attributes must be declared in the protocol class body
or inherited from a superclass. We previously accepted attributes
introduced only by assignments to `self` inside protocol methods, even
though those attributes are not part of the protocol interface.

This emits `ambiguous-protocol-member` for ordinary, annotated,
annotation-only, and augmented assignments to undeclared protocol
instance attributes:

```python
class Template(Protocol):
    name: str

    def method(self) -> None:
        self.temp: list[int] = []  # warning: undeclared protocol member
```

Closes https://github.com/astral-sh/ty/issues/3758.
2026-06-24 19:07:51 +00:00
Dhruv Manilawala c24ded8ef6 Update ruff_python_parser README for crates.io (#26315)
## Summary

This PR updates the parser README to:
1. Link the parser README's AST reference to the published
`ruff_python_ast` crate
2. Remove the obsolete "Python version support" section now that version
specific syntax errors are implemented

Additionally, I've also updated the README generator to add a
"Versioning" section while preserving the rest of the handwritten README
and updated the generator to refresh marker-delimited versioning
sections. Maybe this is not worth doing, let me know if that's the case.

### Review

-
https://github.com/astral-sh/ruff/pull/26315/commits/5a4145a37436872c197c7de9771a04e91f4f0500
- updates the README manually as mentioned in (1) and (2) above
-
https://github.com/astral-sh/ruff/pull/26315/commits/dcb59253c41ecbebacd919defcbb725461a95478
- updates the README generator to add the versioning section

## Test plan

Here's the [Rendered
README](https://github.com/astral-sh/ruff/blob/dcb59253c41ecbebacd919defcbb725461a95478/crates/ruff_python_parser/README.md)
for preview.

Ran `uv run --script scripts/generate-crate-readmes.py` twice and
verified idempotent output
2026-06-24 12:07:14 +05:30
Charlie Marsh 7f0436561d Bump version to 0.15.19 (#26291) 2026-06-23 20:42:26 -04:00
Charlie Marsh dff016b7a4 Publish Ruff crates to crates.io (#26271)
## 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.
2026-06-23 12:49:23 -04:00
Charlie Marsh 4e54b8b771 [ty] Recognize exhaustive matches over finite tuples (#26132)
## Summary

Prior to this change, we could recognize exhaustive match statements
when a fixed tuple's finite combinations were written as an explicit
union, but not when those alternatives were hidden inside the tuple
element types:

```python
def f(b_1: bool, b_2: bool) -> int:
    match (b_1, b_2):
        case (True, True):
            return 0
        case (False, _):
            return 1
        case (_, False):
            return 2
```

We now share the existing bounded type-expansion logic used during
overload resolution and use the expanded union when computing match
reachability. For `tuple[bool, bool]`, this lets each preceding case
subtract the combinations it covers until no alternatives remain.

The expanded type is used only for reachability, so subject and capture
inference remain unchanged. Tuple products remain capped at 64
alternatives; larger products keep the existing conservative behavior.
This also resolves the existing `tuple[int | str]` sequence-pattern
exhaustiveness TODO.

Closes https://github.com/astral-sh/ty/issues/3807.
2026-06-22 20:51:07 -04:00
Brent Westbrook 6686f63404 Bump 0.15.18 (#26135) 2026-06-18 11:07:24 -07:00
Charlie Marsh eea5ddd3c0 [ty] Update Pyrefly benchmark snapshots (#26125)
## Summary

This fixes an oversight from #26110, where we bumped the benchmark
Pyrefly pin to 1.1.0 but did not update the expected Pyrefly benchmark
snapshots.
2026-06-18 06:48:09 -04:00
Charlie Marsh 1bc7712633 [ty] Update benchmark Pyrefly to 1.1.0 (#26110)
## Summary

Update the ty benchmark harness to use Pyrefly 1.1.0.

This only changes the benchmark dependency pin and lockfile. Benchmark
outputs and diagnostic snapshots are intentionally left unchanged.

## Test Plan

- `cd scripts/ty_benchmark && uv lock --upgrade-package pyrefly`
- `cd scripts/ty_benchmark && uv run --python 3.14 pyrefly --version`
- `uvx prek run --files scripts/ty_benchmark/pyproject.toml
scripts/ty_benchmark/uv.lock`
2026-06-17 13:19:23 -04:00
Charlie Marsh 1d5d491001 [ty] Update benchmark project revisions (#25730)
## Summary

This PR bumps the project revisions used by `ty_benchmark` and refreshes
the expected CLI diagnostic snapshots against current upstream code.

The refreshed revisions require a few corresponding dependency changes.
Home Assistant now installs its full and test requirements separately
and excludes `dtlssocket`, which is pulled in by `pytradfri[async]` but
only distributed as an sdist that requires `autoconf`; pandas-stubs now
requires Python 3.11 and exposes its development dependencies through a
dependency group; and PyTorch's import environment is refreshed from its
upstream Pyrefly linter configuration while checker versions remain
controlled by this benchmark.

The benchmark harness now installs mypy only when a mypy suite is
selected, and uses a `uv` override to pin those runs to mypy 2.1.0 even
for projects that declare their own mypy development dependency. This
keeps ty and Pyrefly runs from inheriting mypy's Python-version and
dependency constraints while preserving one benchmark-managed mypy
version for mypy runs.

We also advance the dependency cutoff and update the benchmarked type
checkers to mypy 2.1.0, Pyright 1.1.410, and Pyrefly 1.0.0.
2026-06-17 10:17:22 -04:00
Brent Westbrook 7c645a9a1b Bump 0.15.17 (#25872) 2026-06-11 10:08:53 -07:00
Alex Waygood 7d0c0d1f17 Bump docstring-adder pin (#25777)
## Summary

Pulls in https://github.com/astral-sh/docstring-adder/pull/169, so that
we have a version of docstring-adder that supports 3.15. This enables us
to add docstrings for the new-in-3.15 branches in typeshed.

I also switched us to temporarily use a version of Black from git,
because I'm too impatient to wait for a release that includes
https://github.com/psf/black/commit/f665703258bfa1916f8a6c1cbab0bc384b90cbac.

## Test Plan

CI on docstring-adder
2026-06-09 13:41:56 +00:00
Alex Waygood 196ce476af Streamline ty ecosystem summary workflow (#25654)
## Summary

- make the ecosystem-summary skill concise and output-focused, with an
explicit report template and separate subagent guidance
- capture the exact historical Ruff, ecosystem-analyzer, mypy-primer,
Python, and dependency-cutoff inputs from a GitHub Actions run
- move detailed minimization guidance into a reference and clarify how
primer projects must be reproduced

## Test plan

- `./scripts/collect_ty_ecosystem_run_metadata.py --help`
- validate both updated skills with `quick_validate.py`
- `uvx prek run --files <all changed files>`
2026-06-05 13:35:16 +01:00
Brent Westbrook 6c498ab539 Bump 0.15.16 (#25635) 2026-06-04 09:15:41 -07:00
renovate[bot] 0b982ea69c Update dependency pyright to v1.1.410 (#25566) 2026-06-02 22:19:49 -04:00
Alex Waygood a6ad57f5c2 Commit scripts/uv.lock (#25517)
## Summary

Some of the scripts in this directory are standalone PEP-723 scripts,
but other scripts in this directory depend on the dependencies in
`scripts/pyproject.toml` being installed. If you run any of these
scripts with `uv run`, uv creates a `scripts/uv.lock` file, but we
haven't committed it up till now. We probably should, for
reproducibility and security apart from anything else. It also makes
life less confusing for agents, which are often perturbed by generated
files unexpectedly popping up locally.
2026-06-01 11:54:51 +01:00
Alex Waygood 6627489bda Further improve instructions for agents for working on ty (#25430)
## Summary

A bunch of followup changes from
https://github.com/astral-sh/ruff/pull/25422. Mostly triggered by using
the skill for the first time to analyze the report in
https://github.com/astral-sh/ruff/pull/24761.

- Move ty-specific guidance from `AGENTS.md` to a new local
`working-on-ty` skill. Link to the other ty-specific skills from that
skill.
- Add more keyword triggers to various skills so that agents are more
likely to automatically figure out that a skill is appropriate
(suggested by @dhruvmanila).
- Add more guidance to the ecosystem-minimization skill (and tweak the
script for setting up a primer project) so that agents are likely to
reproduce results in a deterministic and helpful way.

## Test Plan

I repeatedly ran `/review` with Codex on this until the only remaining
issues were trivial.
2026-05-29 11:27:01 +00:00
Brent Westbrook db5aa0a5f1 Bump 0.15.15 (#25431) 2026-05-28 06:54:03 -07:00
Brent Westbrook 9ad2da3015 Bump 0.15.14 (#25295) 2026-05-21 07:17:42 -07:00
Alex Waygood 6cbd59b511 Set exclude-newer = "7 days" in our PEP-723 scripts (#25285)
## Summary

This helps reduce spurious changes to the lockfile if you run these
scripts on a machine that has a global `exclude-newer` value set in a
`~/.config/uv.toml` file or similar. It also seems good more generally
to set an `exclude-newer` value for these scripts: dependency cooldowns
are better for security.

Note that if the machine, hypothetically, also set `UV_DEFAULT_INDEX` as
an environment variable to something other than `pypi.org/simple`, there
would still be changes to the lockfile, so this change may be necessary
but not sufficient for lockfile stability on _certain_ corporate
machines.

## Test Plan

I ensured that the `UV_DEFAULT_INDEX` environment variable was set to
`pypi.org/simple` on my machine and then ran `mdtest.py` using `uv run`.
I didn't run `setup_primer_project.py`, but I did lock it using `uv lock
--script`.
2026-05-21 11:18:48 +00:00
Alex Waygood bd2d6f6353 Update/regenerate various ruff_python_stdlib APIs (#25273)
## Summary

1. Manually update various functions in
`crates/ruff_python_stdlib/src/builtins.rs` to reflect new APIs added in
Python 3.15.
2. Manually remove the incorrect inclusion of `frozenset` from
`is_immutable_non_generic_type` in
`crates/ruff_python_stdlib/src/typing.rs`. `frozenset` is a generic
type.
3. Manually add `frozendict` to `is_immutable_generic_type` and
`is_immutable_return_type` in `crates/ruff_python_stdlib/src/typing.rs`
4. Manually updates to `scripts/generate_builtin_modules.py`: use uv to
invoke Python rather than relying on many different Python versions all
being on `PATH`, drop support for Python 3.7 from the script (it can't
be installed using uv), and apply various other simplifications.
5. Regenerate `is_builtin_module` in
`crates/ruff_python_stdlib/src/sys/builtin_modules.rs` following the
changes made in (4). Note that switching to uv-managed Python installs
(PBS) appears to mean that quite a few more stdlib modules are
recognised as being builtin modules, which is interesting.

I also ran `scripts/generate_known_standard_library.py`, but it didn't
make any changes to the Rust function generated by that script.

## Test Plan

`cargo test`
2026-05-20 14:19:10 +01:00
Charlie Marsh 818da49490 Revert accidental release preview change (#25159)
This was an accidental change for testing in
[astral-sh/ruff#25154](https://github.com/astral-sh/ruff/pull/25154).
2026-05-14 13:35:48 +00:00
Brent Westbrook 2afb467ce3 Bump 0.15.13 (#25157) 2026-05-14 13:18:49 +00:00
Charlie Marsh 2522549901 Remove shellcheck from prek (#25154)
## Summary

`shellcheck-py` requires a build-time binary download from GitHub, which
is rejected by some firewalls. There's also
[`shellcheck-precommit`](https://github.com/koalaman/shellcheck-precommit),
but that uses a Docker-based hook, and would introduce a Docker
requirement to our `prek` setup that doesn't currently exist.

So this PR just removes it from our pre-commit setup, and uses
`actions/setup-go` instead with a dedicated CI job.
2026-05-14 12:34:07 +01:00
Micha Reiser 60d75d7226 Update known stdlib (#25103)
## Summary

This adds preliminary support for Python 3.15. We'll need to re-run the
script before releasing stable 3.15 support.

Closes
https://github.com/astral-sh/ruff/issues/25100#issuecomment-4420254119

Related to https://github.com/astral-sh/ruff/issues/21119

## Test Plan

Added test
2026-05-11 07:39:24 -07:00
Alex Waygood 766e2a13bf Bump docstring-adder pin (#25092)
## Summary

and stop attempting to sync Python 3.9 docstrings, since typeshed no
longer has any 3.9 branches.

I wanted to start syncing the Python 3.15 docstrings, but
docstring-adder cannot add support for Python 3.15 until libcst adds
support for 3.15 upstream.
2026-05-10 23:44:13 +00:00
Charlie MarshandBrent Westbrook 41f8a525b3 Add a rule to flag lazy imports that are eagerly evaluated (#25016)
## Summary

This PR adds a new rule (`TID255`) to flag PEP 810 lazy imports that are
resolved immediately during module import execution.

For example:

```python
lazy import foo

class Bar(foo.Foo): ...
```

Here, `foo` is evaluated while the module is being loaded, so the import
is not meaningfully lazy.

We're also offering an unsafe fix to remove `lazy` when the import
statement imports a single member.

Closes https://github.com/astral-sh/ruff/issues/25014.

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
2026-05-06 20:48:23 +00:00
Charlie Marsh 35228e5a84 [ty] Respect commented-out lines in the conformance test suite (#24932)
## Summary

We were treating this line from the conformance tests as a false
negative:


https://github.com/python/typing/blob/5a701a037b5243df1f39622b642893d865f06205/conformance/tests/generics_syntax_infer_variance.py#L72
2026-04-29 12:56:26 -04:00
renovate[bot] cb11ec4ba4 Update dependency pyright to v1.1.409 (#24856)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-27 10:40:23 +02:00
Dylan 66f93cf7ed Bump 0.15.12 (#24815) 2026-04-24 12:36:40 -05:00
Amethyst Reese 53554b1cfe Bump 0.15.11 (#24678) 2026-04-16 11:17:46 -07:00
Charlie Marsh a1bd94d0f6 [ty] Check inherited NamedTuple field conflicts (#24542)
## Summary

Per the spec:

> A named tuple class can be subclassed, but any fields added by the
subclass are not considered part of the named tuple type. Type checkers
should enforce that these newly-added fields do not conflict with the
named tuple fields in the base class.

The spec then provides this example:

```python
class Point(NamedTuple):
    x: int
    y: int
    units: str = "meters"

class PointWithName(Point):
    name: str  # OK
    x: int  # Type error (invalid override of named tuple field)
```

We take a slightly more expansive view here, rejecting any attributes
(with or without an annotation, with or without a default) and
properties in a `NamedTuple` subclass. This seems to match Pyright and
Pyrefly, though Mypy doesn't flag these.

Shadowing an attribute in this way leads to odd behavior that is
probably never what you want, e.g.:

```python
from typing import NamedTuple

class A(NamedTuple):
    x: int

class B(A):
    x: int = 42

b = B(1)

print(b.x)  # 42
print(b[0])  # 1
print(repr(b))  # B(x=1)

b.x = 99

print(b.x)  # 99
print(b[0])  # 1
print(repr(b))  # B(x=1)
```
2026-04-14 11:30:54 -04:00
renovate[bot] 3127232161 Update dependency pytest to v9.0.3 (#24629)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-14 08:34:15 +02:00
Charlie Marsh 08b0218b3e [ty] Improve consistency of pedantic lints complaining about badly named types (#24575)
## Summary

We now use the same error code for all of these, with the same range,
and it's a warning by default:
```python
N = NamedTuple("O", [])
TD = TypedDict("TE", {})
T = TypeVar("U")
P = ParamSpec("Q")
NT = NewType("N", int)
```

It also implements more graceful recovery for `TypeVar`,
`TypeAliasType`, `ParamSpec`, and `NewType`.

Closes https://github.com/astral-sh/ty/issues/3255.
2026-04-12 13:42:16 -04:00
Brent Westbrook 252f76102a Bump 0.15.10 (#24519) 2026-04-09 09:48:41 -04:00
2f839db9e4 [ty] respect __new__ and metaclass __call__ return types (#24357)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Co-authored-by: Denys Zhak <denyszhak@gmail.com>
2026-04-03 09:10:34 -07:00
Dylan 724ccc1ae8 Bump 0.15.9 (#24369) 2026-04-02 12:59:00 -05:00
Amethyst Reese c2a8815842 Release 0.15.8 (#24217)
- **changelog**
- **everything else**
2026-03-26 11:20:09 -07:00
Micha Reiser 84ff94b42e [ty] Support type:ignore[ty:code] suppressions (#24096) 2026-03-24 09:33:41 +01:00
Brent Westbrook 0ef39de46c Bump 0.15.7 (#24049) 2026-03-19 12:09:44 -04:00
David Peter 7f275f431b [ty] Pin mypy_primer in setup_primer_project.py (#24020)
## Summary

Pin mypy_primer (reference:
https://github.com/astral-sh/ruff/pull/24016#discussion_r2947047615)
2026-03-17 21:26:10 +01:00
David Peter dc59ffa9c6 [ty] Remove the mypy_primer CI workflow (#24016)
## Summary

Remove the mypy_primer CI workflow and several files/scripts associated
with it.

## Test Plan

Successful CI run on this PR
2026-03-17 15:49:55 +01:00
David Peter 65d5edc319 [ty] Include CPython projects in ecosystem-analyzer runs (#23995)
## Summary

There are three special projects in mypy_primer's list: they are all
part of the cpython repository, but in different subfolders. Previously,
`good.txt` only included the pattern "cpython" to include all of them
for mypy_primer runs. However, ecosystem-analyzer expects an exact
match. I don't really want to change that behavior in
ecosystem-analyzer, so instead, we now include the full project names,
and map those back to "cpython" for mypy_primer (which matches the regex
against the projects URL, not the name).

## Test Plan

- Made sure that mypy_primer still runs as expected, with the new
selector (regex-escaping leads to a slightly different project selector)
- Made sure that CPython projects are now included in ecosystem-analyzer
runs
2026-03-16 11:33:37 +01:00