## 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
## 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
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`
## 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.
## 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
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.
## 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.
## 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`
## 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.
## 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>`
## 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.
## 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.
## 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`.
## 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`
## 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.
## 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.
## 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>
## 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)
```
## 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.
## 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