Commit Graph
65 Commits
Author SHA1 Message Date
Charlie Marsh 7e6e899c10 [ty] Skip union comparisons between methods of distinct functions (#30721)
## Summary

Telethon looks up `clazz.from_reader` on a union of more than 2,000
classes. To build the union of bound methods, ty caches millions of
comparisons that fail as soon as we check the underlying functions.

We now check function identity in the union builder. Methods backed by
distinct function literals expose different `__func__` values even if
their signatures match. We still visit each pair and use the existing
checks for methods that share a function.

Cold checks of all 150 Python files in [Telethon
1.42.0](https://pypi.org/project/Telethon/1.42.0/) used 50.85–50.94%
fewer Cachegrind instructions. Median peak RSS fell from 1,776 to 487
MiB and the number of interned type pairs fell from 5,634,936 to
395,254.

On all 156 files in [Telethon
1.45.0](https://pypi.org/project/Telethon/1.45.0/), instructions fell by
51.93–52.00% and median peak RSS fell from 2,106 to 546 MiB.

<!-- ty-pinned-project-instructions:start -->
| Project | [Base
instructions](https://github.com/astral-sh/ruff/commit/943f623f55c9aa625b0b1b21af731e451819accc)
| [PR
instructions](https://github.com/astral-sh/ruff/commit/8d03b8535c23330cded93a3b4300cdb427ca8f95)
| Change | Paired range |
| --- | ---: | ---: | ---: | ---: |
|
[Black](https://github.com/psf/black/tree/55996d1fb8342725c8a19b6023cd9439c3c1d6f7)
(inconclusive) | 3,114,464,876.5 | 3,110,414,506 | -0.13% | -0.29% to
+0.03% |
|
[discord.py](https://github.com/Rapptz/discord.py/tree/65232c38702be5844cf2ce865a4777eb1928b5d0)
(inconclusive) | 7,987,516,040 | 7,993,539,938.5 | +0.08% | -0.19% to
+0.34% |
| [Home
Assistant](https://github.com/home-assistant/core/tree/c19ae285ede74cd64c3045a3a4aa43290c224f1b)
| 153,590,539,496 | 153,638,289,742 | +0.03% | +0.02% to +0.04% |
|
[isort](https://github.com/pycqa/isort/tree/a514c71ed86c2216d0040c7d60e302ed76a4f7ab)
(inconclusive) | 1,816,340,726 | 1,816,898,305.5 | +0.03% | -0.04% to
+0.10% |
|
[Jinja](https://github.com/pallets/jinja/tree/5ef70112a1ff19c05324ff889dd30405b1002044)
(inconclusive) | 1,899,232,704.5 | 1,901,946,299 | +0.14% | +0.09% to
+0.20% |
|
[pandas](https://github.com/pandas-dev/pandas/tree/a0225b65720018f4654390bb16d254daa6ee5e54)
(inconclusive) | 27,648,069,329.5 | 27,633,817,015.5 | -0.05% | -0.10%
to 0.00% |
|
[pandas-stubs](https://github.com/pandas-dev/pandas-stubs/tree/8dd6d91b1c05b26e30f7ddbe3dc3d4042a92bdd6)
(inconclusive) | 2,875,891,658 | 2,874,361,007 | -0.05% | -0.18% to
+0.08% |
|
[Prefect](https://github.com/PrefectHQ/prefect/tree/a9452ac21852755311913cb27887b083b5007c03)
(inconclusive) | 4,866,071,962.5 | 4,868,306,269 | +0.05% | +0.02% to
+0.08% |
|
[PyTorch](https://github.com/pytorch/pytorch/tree/ab92945cea42e47ae398aead69af0872d340ea0f)
(inconclusive) | 93,380,078,394 | 93,453,373,652 | +0.08% | -0.05% to
+0.21% |
|
[HTTPX](https://github.com/encode/httpx/tree/b5addb64f0161ff6bfe94c124ef76f6a1fba5254)
| 1,651,220,747 | 1,654,539,098.5 | +0.20% | +0.20% to +0.20% |
|
[NumPy](https://github.com/numpy/numpy/tree/f9f1772ce010001208475f751d19253469788410)
(inconclusive) | 8,216,717,078.5 | 8,229,302,158 | +0.15% | +0.09% to
+0.22% |
|
[FastAPI](https://github.com/fastapi/fastapi/tree/7a0a3f0b286c6c865cf4398ea0e957a87b8bffa4)
(inconclusive) | 2,945,954,611 | 2,947,488,094 | +0.05% | +0.03% to
+0.08% |
|
[SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy/tree/10f4d1e2d706a7722ca78e79ce05b00333a7aa5b)
(inconclusive) | 20,741,429,829.5 | 20,744,124,996.5 | +0.01% | +0.01%
to +0.02% |
|
[Rich](https://github.com/Textualize/rich/tree/9d8f9a372cc5916fd4781fec207ced7ddac2f08f)
(inconclusive) | 2,679,182,569.5 | 2,677,272,692.5 | -0.07% | -0.48% to
+0.34% |
|
[Django](https://github.com/django/django/tree/b501b8493f31cf8cba31211d59b3b78642b8cb02)
(inconclusive) | 13,418,704,481.5 | 13,430,801,584 | +0.09% | +0.02% to
+0.17% |
|
[SymPy](https://github.com/sympy/sympy/tree/85d3998a4517ffbc8a9709b8efa769bb417c174a)
(inconclusive) | 44,750,288,715.5 | 44,789,077,339.5 | +0.09% | +0.02%
to +0.15% |
| [OpenAI Python
SDK](https://github.com/openai/openai-python/tree/f6e8480f9a5b2a4d02b17a1da54a1e57964bc312)
| 15,434,514,718 | 15,457,492,616.5 | +0.15% | +0.15% to +0.15% |
|
[pytest](https://github.com/pytest-dev/pytest/tree/8b005ed7f972987033ec34dc1e68b0635fb8142b)
| 8,591,821,941 | 8,604,767,453 | +0.15% | +0.10% to +0.20% |
|
[aiohttp](https://github.com/aio-libs/aiohttp/tree/fe099491d275ef2c21bf683e024e34d51ac05d43)
(inconclusive) | 4,070,623,526.5 | 4,066,976,082.5 | -0.09% | -0.13% to
-0.04% |
|
[Ansible](https://github.com/ansible/ansible/tree/b4b2b1e82a535d27f902a71fc8396c3af138fca2)
(inconclusive) | 14,015,160,770.5 | 14,026,286,697.5 | +0.08% | 0.00% to
+0.15% |
|
[botocore](https://github.com/boto/botocore/tree/e250abbe956da791c16086575e6ddb1f2da81a78)
(inconclusive) | 2,935,279,055 | 2,934,176,450.5 | -0.04% | -0.07% to
-0.01% |
|
[Celery](https://github.com/celery/celery/tree/9c2f238334331db43f15956f131235fd3bb70fd1)
(inconclusive) | 4,651,480,837 | 4,653,743,507 | +0.05% | +0.04% to
+0.06% |
|
[Dask](https://github.com/dask/dask/tree/249a51a1db4261791b93b4ce04e67341729939c3)
(inconclusive) | 32,512,163,503.5 | 32,514,936,889 | +0.01% | 0.00% to
+0.01% |
|
[NetworkX](https://github.com/networkx/networkx/tree/6855cd586982cc2e4710b8eb87251ccf56674bf1)
(inconclusive) | 15,213,287,215.5 | 15,219,151,727 | +0.04% | -0.03% to
+0.10% |
|
[Pydantic](https://github.com/pydantic/pydantic/tree/560f0f96a37d6913afdfddb2de22030ef08e68c3)
| 12,884,688,971.5 | 12,909,835,715 | +0.20% | +0.16% to +0.23% |
|
[scikit-learn](https://github.com/scikit-learn/scikit-learn/tree/ee56c8b5d809dc7b970a140ed501269b63c69cf8)
| 58,217,509,201 | 58,254,050,951 | +0.06% | +0.04% to +0.08% |
|
[Scrapy](https://github.com/scrapy/scrapy/tree/e63a574c767d7a9438c21db158f605f1c44c6e6a)
(inconclusive) | 8,737,403,792 | 8,728,786,127.5 | -0.10% | -0.16% to
-0.04% |
|
[Transformers](https://github.com/huggingface/transformers/tree/3a134bc37f7c22c801b618e289b0255425f22647)
(inconclusive) | 96,483,800,171.5 | 96,522,588,263.5 | +0.04% | +0.01%
to +0.07% |
<!-- ty-pinned-project-instructions:end -->
2026-11-21 22:23:25 -05:00
Alex Waygood 0507c5f66c [ty] Rename call-non-callable to not-callable (#30284) 2026-11-12 11:52:16 +00:00
Alex WaygoodandBrent Westbrook ce0077c3e5 [ty] Distinguish attributes missing from some union members (#29944)
## Summary

Users can now suppress an attribute error that affects only some union
members and still catch names that are missing from every member. For
example, both lines below previously reported `unresolved-attribute`:

```python
def clean(value: str | int) -> str:
    value.stirp()          # missing-attribute: neither str nor int has stirp
    return value.strip()   # missing-union-attribute: str has strip, int does not
```

The motivation is that a project adopting ty may want `value.strip()` on
`str | None` to only warn while a typo remains an error-severity
diagnostic.

Both rules default to errors. The same distinction applies to optional
values such as `str | None` and to attribute deletion. Attributes
defined only conditionally on a class continue to use
`possibly-missing-attribute`.

### Comparison to other type checkers

Pyright distinguishes between `reportOptionalMemberAccess` (which is
specifically for unions with `None`) and `reportAttributeAccessIssue`,
which is for all other unions. mypy, meanwhile, distinguishes between
`union-attr` (which is an error code for all attribute-access errors on
union types) and `attr-defined` (which is an error code for all
attribute-access errors on non-union types). So this new split doesn't
_exactly_ align with either precedent -- but I _do_ think it's probably
the most useful split we can do, and it's the one that makes the most
sense _a priori_ in my opinion.

### Compatibility

`unresolved-attribute` remains an alias for `missing-attribute` in
configuration and inline ignores. To preserve a setting such as
`unresolved-attribute = "warn"` for both cases, also set
`missing-union-attribute = "warn"`. On an access that fails for only
some union members, replace `# ty: ignore[unresolved-attribute]` with `#
ty: ignore[missing-union-attribute]`. Tools that consume diagnostic
codes should recognize both new names.

Fixes astral-sh/ty#2839 and fixes astral-sh/ty#2471.

## Test Plan

A comparison with ty 0.0.96 on typeshed-stats, docstring-adder,
sphinx-lint, and typing_extensions found the same messages, locations,
and severities. Eight diagnostics received `missing-union-attribute`
across those four projects (two in sphinx-lint and six in
typing_extensions).

---------

Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2026-11-06 14:46:50 -05:00
Charlie MarshandCharlie Marsh 8fd003a32d [ty] Skip union checks for incomparable types (#30102)
## Summary

Django calls `.encode()` on a union of hundreds of string literals.
Looking up the method produces a bound method for each literal. When
building the union of those methods, ty compared every pair even though
their distinct `__self__` values already distinguish them.

We now skip the subtype and complement checks for methods bound to
distinct singleton literals. `LiteralString` still needs the general
check because it can include a particular literal. Distinct class
objects, distinct module objects, and a dynamic type paired with a
nominal instance other than `object` can also skip the checks.

A cold `ty check` of Django used 3.27% fewer instructions.

---------

Co-authored-by: Charlie Marsh <charliemarsh@openai.com>
2026-11-06 14:50:48 +00:00
David Peter 324bcac22e [ty] Support shadowing methods on instances (#29482)
## Summary

With this PR, we now support the following scenario where a function on
a class is shadowed by an instance attribute:

```python
class C:
    def method(self, x: int) -> str:
        return str(x)

    def some_compatible_method(self, x: int) -> str:
        return str(x)

    def swap(self) -> None:
        self.method = self.some_compatible_method  # previously an error

c = C()
c.swap()
c.method(42)  # previously an error (two, actually)
```

(see [this
section](https://github.com/astral-sh/ruff/blob/078b001e5c09f9c301ee7d91092b4946d0591d63/crates/ty_python_semantic/resources/mdtest/call/methods.md#shadowing-methods)
for an in-depth description of what happens here)

Shadowing a method in this way is only sound in a small number of cases.
We deliberately relax conditions here to support various use cases that
came up in the ecosystem. We only require the shadowing callable
(`self.some_compatible_method` above) to be assignable to the
(generalized, regular) callable type of the original `method` after that
has been bound to the receiver in question (`self` here).

See the mdtests linked above for a broaded discussion of the unsoundness
that this introduces. We plan to add a new strict-mode diagnostic for
users who want to prevent those scenarios.

We implement this in the following way:
- When validating the assignment `self.method = ...`, we compare the
right-hand side callable with a "contract type" that is computed from
the bound-method type of the original method, which results in (`(x:
int) -> str`) for the example above. This allows the assignment above to
pass.
- During attribute lookup (`c.method`), we "hide" the implicit instance
attribute (this needs to be done in two places, unfortunately). This
means that `c.method` only sees the original function on the meta type
`C` (and no "fallback" on the instance). And so according to normal
descriptor protocol rules, this means that we simply get a bound method
object (`C.method` bound to `c`). This avoids confusing and problematic
union types that consist of (a) the bound method resulting from binding
the original function to the new receiver and (b) the bound method
referring to the `self` receiver which is stored on the instance. It
might also be a performance optimization.

fixes astral-sh/ty#350.
fixes astral-sh/ty#4823.

## Ecosystem

Looks good. A few exceptions:

- GraphQL-core: I documented this regression in an mdtest. See my inline
comment
- hydra-zen: This is a pre-existing limitation. I reported
https://github.com/astral-sh/ty/issues/4926

## Testing

Updated existing mdtests
2026-11-05 15:31:31 +01:00
David Peter 3c250eccbb [ty] Tests for method shadowing (#29988)
## Summary

Add an explanation of how and why method shadowing works at runtime, and
add tests for the upcoming fixes for
https://github.com/astral-sh/ty/issues/350.
2026-11-04 11:38:03 +01:00
Carl Meyer e26e6d2a54 [ty] Collect intersection inference through constraint relations (#28677)
Intersection arguments to generic functions can offer several valid
specializations, with relationships between their type variables and
other arguments. Collect these constraints through the full
constraint-set-assignability type relation so inference preserves
variance, alternatives, and correlations. For example, another argument
can select `T = A` from the alternatives provided by `Sink[A] &
Sink[B]`.

There are some cases we have to carve out:
- Constraint-set assignability can currently lose constraints when
gradual types are involved. https://github.com/astral-sh/ruff/pull/28307
will fix this; until then we have to keep gradual types in the old
solver to avoid regression.
- ParamSpec and TypeVarTuple must be kept in the old solver until the
new solver supports them. This includes callables with `ParamSpec` or
`TypeVarTuple` that are nested inside an intersection. We don't handle
this problem in general, but by far the most common case is an
intersection with `~AlwaysTruthy` or `~AlwaysFalsy`. We avoid regression
in that scenario by, whenever we have a single-positive-element
intersection in covariant position, dropping the negative element(s) and
recursing into the positive element in the old solver, instead of
passing the intersection to the new solver. This is a sound upcast, and
negative intersection elements generally don't contribute any
constraints to generics solving.

This depends on #29014 for validating declared upper bounds when an
inferred specialization contains caller-fixed type variables.

This partially addresses astral-sh/ty#3557 and astral-sh/ty#2799.
Argument checking and return inference still use the union-merged
specialization when there are multiple valid solutions, and we haven't
moved unions into the new solver yet.

Fixes astral-sh/ty#3719.

## Ecosystem report

Analyzed head: `77137c770276c0910f4f8fc14bbaa44f233ee82e`. Four false
positives are removed in Tanjun and xarray; Tornado gains a correct
diagnostic under strict generic narrowing. The general
caller-fixed-variable solver limitation also reproduces on main and is
tracked separately in
[ty#4696](https://github.com/astral-sh/ty/issues/4696). [Full ecosystem
report](https://github.com/astral-sh/ruff/pull/28677#issuecomment-5780439815).
2026-10-14 11:34:03 -07:00
David Peter 8546752d9d [ty] Fix member lookup on union-bounded type variables (#29018)
## Summary

Consider the following example where we call a method on an object of
type `T: E1 | E2`:

```py
class E1:
    def f(self) -> list[Self]:
        return [self]

class E2:
    def f(self) -> set[Self]:
        return {self}

def _[T: E1 | E2](obj: T):
    reveal_type(obj.f())
```

How should the `obj.f` attribute access be resolved? We can't bind
`E1.f` to the full `T: E1 | E2` type, since that would invalidate the
implicit `self: Self` annotation of `E1.f`, with `Self: E1`. But we can
use a trick: we can observe that `T = T & (E1 | E2)`. This is true
because `T` is a subtype of `E1 | E2` due to its bound, and so
intersecting `T` with `E1 | E2` just gives us `T`. We can expand that to
get `T = T & E1 | T & E2`. And on the two elements of this union type,
we *can* actually access `E1.f` and `E2.f`, respectively. Accessing `f`
on the first union element `T & E1` gives us `E1.f` as a bound method
with a receiver of `T & E1`, which is accepted by `Self: E1`. After
doing the same for the second union element, we get:
```
(bound method E1.f with receiver T & E1) | (bound method E2.f with receiver T & E2)
```

This means that the result of this call should be `list[T & E1] | set[T
& E2]`. Mypy reveals `list[E1] | set[E2]` here, which seems clearly
wrong. Pyrefly infers the expected intersection types. And Pyright
infers `list[E1*] | set[E2*]` where the stars indicate some
intersection-like connection to the typevar, so this also seems
consistent.


fixes https://github.com/astral-sh/ty/issues/2585
fixes https://github.com/astral-sh/ty/issues/3871

## Ecosystem

Looks good!

*"The two additions are an extra copy of an existing discord.py argument
error and a pre-existing xarray setter error exposed when arithmetic
preserves the receiver type instead of producing `Unknown`."*

## Test Plan

New and updated Markdown tests.
2026-10-01 14:43:02 +00:00
Carl Meyer f76b23f4d1 [ty] Report deprecated overloads in decorator applications (#28999)
ty did not report a deprecation when applying a decorator selected a
deprecated overload. This missed, for example, the deprecated
`AsyncIterator` annotation on `@asynccontextmanager`.

Report deprecations for overloads selected by function and class
decorator applications. Avoid repeating deprecation warnings for
explicitly referenced functions while retaining warnings for implicitly
invoked callable and constructor methods.

Fixes astral-sh/ty#4620.

## Test plan

Added mdtests for deprecated and non-deprecated overloads on function
and class decorators, dataclass transformers, callable instances, and
constructors. They also cover conditional and stacked decorators,
implicit methods and constructor chains, deprecated implementations,
`no_type_check`, and `asynccontextmanager`.

## Ecosystem report

At PR head
[`7e04af3dcb77c131dbd2865a324df4c69a5810b4`](https://github.com/astral-sh/ruff/commit/7e04af3dcb77c131dbd2865a324df4c69a5810b4),
the ecosystem run found 491 additional `deprecated` warnings across 73
projects: 468 for context-manager decorators and 23 for
pytest-robotframework's `keyword` decorators. The warnings are
consistent with equivalent explicit calls and do not block readiness.
Some messages are misleading when the function's return type is
`Unknown` or an already-annotated `Generator` has a narrower send type.

[Full ecosystem
report](https://github.com/astral-sh/ruff/pull/28999#issuecomment-5897426490)
2026-09-29 19:28:05 -07:00
8764ca72a9 [ty] Bound methods without a receiver are not callable (#28981)
A method that cannot accept its implicit positional receiver can
currently satisfy a callable contract, including a protocol method or
`Callable[[], int]`, even though calling the bound method fails.

Record an unsatisfiable receiver constraint when binding has no
positional capacity. Homogeneous `*args` continues to accept and
constrain the receiver, and fixed unpacked tuples consume their leading
argument. Regression tests cover protocol and callable assignments,
descriptors, variadics, and overloads. The related method-override
snapshot is updated.

Closes astral-sh/ty#4158.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Co-authored-by: David Peter <mail@david-peter.de>
2026-09-29 15:56:40 +02:00
Carl Meyer 4b45f36fa6 [ty] Correct descriptor prose in method documentation (#28765)
The method documentation incorrectly described `classmethod` descriptors
as unmodeled and `inspect.getattr_static` as unwrapping `staticmethod`
descriptors. Clarify that static lookup returns the descriptor, while
ordinary attribute access returns a bound class method or the underlying
static method function. Explain why the descriptor's revealed type still
uses the wrapped function's name and signature.

## Test plan

This changes prose only; the existing mdtest examples and expected type
displays are unchanged. Checked the explanations against the
implementation and the descriptor tests in `call/getattr_static.md`.
File-scoped Markdown hooks pass.
2026-09-22 10:32:59 +02:00
David Peter 472441936b [ty] Add test suite for union and intersection method receivers (#28614)
## Summary

Reorganize and add new (hand-written) tests for method calls on union
and intersection types. This is in preparation for fixes to the
following issues:

- https://github.com/astral-sh/ty/issues/4075
- https://github.com/astral-sh/ty/issues/2585
- https://github.com/astral-sh/ty/issues/3871

Based on: https://github.com/astral-sh/ruff/pull/28410
2026-09-18 12:04:36 +02:00
David Peter b0d28ca41f [ty] More faithful representation of bound methods (#28410)
## Summary

This PR changes our representation of `BoundMethodType` so that it can
cover more use cases. In particular, we can now retain the full
`BoundMethodType` (including the underlying function and the captured
receiver) for decorated and synthesized callables. For example,
`SomeDataclass.__init__` is now a bound method, instead of just a
function-like callable with an eagerly bound signature.

This allows us to model the behavior of these types more precisely. For
example, we now recognize that they have attributes like `__self__` or
`__func__`. This addresses https://github.com/astral-sh/ty/issues/1452
and leads to some ecosystem improvements like this example from Bokeh:

```py
class Node:
    @staticmethod
    def visit_html(visitor, node):
        ...

    html = visit_html.__func__  # previously an error
```

Due to the more faithful representation of these types, we now also
start to allow overrides of `classmethods`s with `staticmethods`s, and
instancemethods with `staticmethods`. This is also where the bulk of the
ecosystem changes come from. For example, we now allow the following
pattern, which appears to be rather common in cases where the subclass
doesn't need the `cls` parameter for the implementation (mypy and
pyrefly also allow this; pyright emits a wrong/confusing error):

```py
class Base:
    @classmethod
    def f(cls, x: int): ...

class Sub(Base):
     # previously `invalid-method-override`, now allowed
    @staticmethod
    def f(x: int): ...
```

closes https://github.com/astral-sh/ty/issues/1452
closes https://github.com/astral-sh/ty/issues/4504
closes https://github.com/astral-sh/ty/issues/4341

also related: https://github.com/astral-sh/ty/issues/4459 (this PR fixes
the error, but need to investigate more)
also related: https://github.com/astral-sh/ty/issues/1172

## Test strategy

Hand-written mdtests (new and updated)
2026-09-18 11:53:01 +02:00
Charlie Marsh f70daaa1b6 [ty] Fix cached classmethods on generic classes (#28207)
## Summary

We now allow cached classmethods to be accessed through generic classes:

```python
from functools import lru_cache
from typing import Generic, TypeVar

T = TypeVar("T")

class Box(Generic[T]):
    @classmethod
    @lru_cache
    def make(cls) -> "Box[T]":
        return cls()

Box.make()  # Previously: invalid-attribute-access.
```

Previously, we recorded `classmethod` and `staticmethod` on the original
function type, but lost that binding information when another decorator
(`lru-cache`) returned a callable object. We now preserve the complete
wrapped callable when constructing these descriptors and use the
existing bound-method representation to bind the class argument. (This
also retains wrapper attributes such as `cache_clear` and
overload-specific return types.)

Closes https://github.com/astral-sh/ty/issues/4431.
2026-09-09 13:13:13 -04:00
Carl Meyer 5c64006c01 [ty] Preserve generic receivers in implicit __init_subclass__ calls (#28138)
A generic subclass with a defaulted type parameter can incorrectly fail
the implicit `__init_subclass__` receiver check. The receiver is
default-specialized while the inherited method's `Self` bound retains
the subclass's type variables, producing a comparison such as
`Child[int]` against `Base[T@Child]`.

Use the subclass's identity specialization for the implicit `cls`
argument so the receiver and inherited hook use the same type
parameters. This accepts valid class definitions while retaining
explicit receiver restrictions and keyword argument validation.

Closes astral-sh/ty#4411.

## Test plan

Added mdtests covering:

- Generic subclass receivers with no defaults, all-default parameters,
and mixed required and defaulted parameters.
- Legacy `TypeVar` defaults and explicit `cls` annotations, including
rejection of incompatible receiver specializations.
- Class keyword arguments, including values typed using a subclass
parameter and rejection of incompatible values.
2026-08-31 15:34:03 +00:00
Carl Meyer 44713bd0f9 [ty] Invalidate member narrowing across loop iterations (#28009)
Reassigning an object inside a loop leaves narrowing of its attributes
or indexed elements in effect from before the loop. This can make a
`while` condition appear permanently true and cause ty to treat
reachable code after the loop as unreachable.

Create loop-header definitions for places invalidated by reassignment,
and include their fallback member types when computing narrowing across
loop-back paths. Preserve narrowing established after reassignment and
the initial narrowing when a reassignment cannot reach another
iteration. Propagate invalidation through nested loop headers with
memoization.

Exclude synthetic loop headers from attribute-assignment discovery:
rebinding a receiver does not write its attributes or initialize `Final`
values. Treat discarded dictionary-key assignments as invalidations so
rejected replacements and property-setter inputs do not become inferred
key values on subsequent iterations.

Fixes https://github.com/astral-sh/ty/issues/4379.

## Ecosystem

The ecosystem run removes 55 false-positive Pydantic errors and one
Pyodide warning. It adds three expected websockets diagnostics by making
a previously unreachable `join` reachable; the existing annotations
allow mixed text and binary fragments. Minimized reproductions confirm
these changes are expected, with no regressions found.

## Test plan

- Extend `while` and `for` mdtests to cover condition, body, and
normal-exit narrowing after object replacement, explicit `continue`,
nested-loop early exits, nested attributes, and subscripts.
- Verify that break-only paths preserve initial narrowing and that
assertions on replacement objects narrow the next iteration.
- Verify method binding before receiver-rebinding loops and at external
calls, and distinguish actual `Final` initialization inside loops from
receiver rebinding.
- Cover accepted and rejected dictionary replacements, narrowing after
rejected replacements, and property setters whose input types differ
from their getters, including loop-carried dictionary values.
2026-08-28 22:26:38 +00:00
Ed Page 958efb1ff4 Vendor latest annotate-snippets (#27033)
## Summary

This is a first step towards #20411. After this, we would work to either
upstream changes or adjust things within Ruff.

Performance improvements have already been upstreamed
(https://github.com/rust-lang/annotate-snippets-rs/pull/437,
https://github.com/rust-lang/annotate-snippets-rs/pull/440)

Re-implemented the following from the fork:
- Hidden snippets
(https://github.com/rust-lang/annotate-snippets-rs/issues/448)
- Renderer-level disabling of hyperlinks
- Jupyter cell indices
(https://github.com/rust-lang/annotate-snippets-rs/issues/449)
- Fixable mark
(https://github.com/rust-lang/annotate-snippets-rs/issues/450)
- `lineno_offset` (maybe not needed if #20648 is taken care of)
- anonymized lines affects origin
(https://github.com/rust-lang/annotate-snippets-rs/issues/451)
- cut indicator (maybe not needed if we can switch to unicode renderer)

Additional hacks to minimize behavior change include
- Adjust upstream's hidden severity behavior to match Ruff's
(https://github.com/rust-lang/annotate-snippets-rs/issues/452)
- How newlines are annotated
(https://github.com/rust-lang/annotate-snippets-rs/issues/454)
- To not indent for line numbers when none will be present
(https://github.com/rust-lang/annotate-snippets-rs/issues/453)
- Enabling `simd` by default

All of the above represents work that needs to be resolved to address
#20411.

`lib.name` hack is used to simplify maintenance with the assumption that
we'll continue working towards #20411.

Behavior changes that were included
- Tweak when implicit padding lines are present
- Fix Origin's line/column is now derived from the primary annotation
- Make consistent the rendering of primary/context annotations
- Fix snippets to show up for empty source (but may degrade #24528)
- Fix handling of term width
- Fix rendering of annotations between newline and first character
(granted, maybe the caller is wrong)
- Tweak multiline annotation markers

New or upcoming features annotate-snippets features that we will be able
to leverage by moving this forward
- `AnnotationKind::Visible` to improve the quality of built-in
code-folding if Ruff were to switch to it
- `DecorStyle::Unicode`
- *(upcoming)* No-graphiscs mode for screen readers (may also be useful
for AIs)

Deferred:
- Moving related `Group`s into the same `Report`
- Using `secondary_title` for any `Group` after the first in a `Report`
- Using a `Snippet`, instead of titles, for "virtual code" like
https://github.com/astral-sh/ruff/pull/27033#discussion_r3622727236
- Switching hidden snippets to `Origin`

## Test Plan

Within cpython, I ran
```console
$ hyperfine -i "../../ruff/target-baseline/release/ruff check" "../../ruff/target-update/release/ruff check" -N -m20 --output=null
Benchmark 1: ../../ruff/target-baseline/release/ruff check
  Time (mean ± σ):      27.5 ms ±   1.1 ms    [User: 33.0 ms, System: 108.4 ms]
  Range (min … max):    25.0 ms …  31.7 ms    94 runs

  Warning: Ignoring non-zero exit code.

Benchmark 2: ../../ruff/target-update/release/ruff check
  Time (mean ± σ):      28.1 ms ±   2.0 ms    [User: 33.4 ms, System: 105.7 ms]
  Range (min … max):    24.8 ms …  38.9 ms    102 runs

  Warning: Ignoring non-zero exit code.
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use t
he '--warmup' or '--prepare' options.

Summary
  ../../ruff/target-baseline/release/ruff check ran
    1.03 ± 0.08 times faster than ../../ruff/target-update/release/ruff check
```

Before:
<img width="486" height="583" alt="image"
src="https://github.com/user-attachments/assets/2d94dabf-b28d-48c1-b17c-52aac59fd57e"
/>

After:
<img width="486" height="583" alt="image"
src="https://github.com/user-attachments/assets/b388ada3-e3d7-4ba0-b90b-1330eb81f4be"
/>
2026-07-28 11:57:09 -05:00
Charlie MarshandCarl Meyer 4ab610a5eb [ty] Preserve Self in __new__ calls (#27003)
## Summary

Prior to this change, calling an inherited `__new__` implementation
could lose `Self` and return `Unknown`. This caused us to miss invalid
attribute access and broke chains of custom `__new__` implementations:

```py
from typing import Self

class Foo: ...

class Bar(Foo):
    def __new__(cls) -> Self:
        return Foo.__new__(cls)

class Baz(Bar):
    def __new__(cls) -> Self:
        result = Bar.__new__(cls)  # Previously: Unknown
        result.nonexistent()  # Previously: no diagnostic
        return result
```

This gives every unannotated `__new__` receiver an implicit
`type[Self]`, matching the constructor typing specification and
preserving `Self` through inherited calls.

It also preserves existing generic constructor calls where the synthetic
`cls` receiver would otherwise be specialized and checked twice. The
regression coverage includes overloaded callbacks, signature-preserving
and callable-protocol decorators, `Concatenate`, and aliased receiver
types; the intentionally odd nested and `Concatenate` inference results
remain documented as pre-existing limitations.

Closes https://github.com/astral-sh/ty/issues/3965.

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2026-07-27 08:35:36 -07:00
Charlie Marsh c588a3f7f5 [ty] Correct protocol method receiver binding (#26701)
## Summary

Prior to this change, we could incorrectly reject a call to a stored
bound method obtained from a class-based protocol. Member lookup has
already specialized the method for its receiver, but calling through a
callable union reconstructed the original signature and prepended the
receiver as a synthetic argument. Generic call inference then
structurally checked the inferred `self` annotation again:

```python
from collections.abc import Iterator
from typing import Any

class PeekIterator(Iterator[Any]):
    def __init__(self, iterator: Iterator[Any]) -> None:
        self._next = iterator.__next__

    def __next__(self) -> Any:
        # Before: Expected `Self@__next__`, found `Iterator[Any]`
        return self._next()

    def use_fallback(self) -> None:
        self._next = lambda: None
```

The receiver is already bound, so `Iterator.__next__` genuinely takes no
call-site arguments and should not be checked against `Self` again. We
now consume an implicit positional receiver before call inference, apply
the `typing.Self` substitution to the remaining signature, and refresh
its return type. This removes the false positive and avoids re-entering
recursive protocol interfaces during binding, which could otherwise
cause overloaded recursive members to grow the deferred constraint graph
combinatorially.

This also corrects constructor diagnostics for class-based protocols.
Previously we counted the implicit receiver in both the expected and
supplied arity:

```python
from collections.abc import Hashable

def construct(value: Hashable) -> None:
    # Before: expected 1, got 4
    # After:  expected 0, got 3
    type(value)(1970, 1, 1)
```

Because binding removes the leading parameter, we preserve its
source-parameter offset so invalid-argument and missing-argument
diagnostics still point at the correct declaration. Explicit, variadic,
keyword-only, and other nonstandard receivers retain the existing
call-inference path; the protocol relation itself is unchanged.

The independent recursive traversal in `redundant-cast` checks is
handled separately in #26708.

Related: <https://github.com/astral-sh/ty/issues/3954>
2026-07-10 21:28:47 -04:00
David Peter 7b3b6a0b8c [ty] Split ty_extensions into public and internal parts (#26586)
## Summary

Split `ty_extensions` into a public part (`ty_extensions`), and an
internal part (`ty_extensions._internal`). For now, move everything to
`_internal`, except for:

- `static_assert`
- `Unknown`
- `AlwaysTruthy`, `AlwaysFalsy`
- `Intersection`, `Not`
- `Top`, `Bottom`
- `JustFloat`, `JustComplex`
- `NamedTupleLike`
2026-07-07 02:32:21 -07:00
Charlie Marsh afa6bcbd5e [ty] Preserve gradual behavior for explicit Any subclasses (#26034)
## Summary

In https://github.com/astral-sh/ty/issues/1686#issuecomment-4343186815,
we decided the following:

> We discussed this internally and our current plan is to treat
instances of `class Mock(Any): ...` as if they were of type `Mock &
Any`. This would enable the use case here, and still give accurate types
(and things like auto-completion) for actual attributes on `Mock`.
> 
> Note that this will mean that we treat `class C(Any): ...` differently
from `class C(SomethingOfTypeAnyOrUnknown): ...`. The latter would still
be a normal class with a dynamic base, i.e. an instance of that class
would not be assignable to arbitrary types.

As such, instances of classes that explicitly inherit from `Any` now
retain their nominal type and precise declared members while remaining
assignable to arbitrary types, including`Final` and `Literal` types:

```python
from typing import Any, final

class Mock(Any):
    def method(self) -> int: ...

@final
class FinalClass: ...

value: FinalClass = Mock()
result: int = Mock().method()
```

Closes https://github.com/astral-sh/ty/issues/1686.
2026-06-19 13:18:01 -04:00
Charlie Marsh 5b47d26162 [ty] Preserve exact class objects during identity narrowing (#26117)
## Summary

Prior to this change, when narrowing `klass is Y` for `T: (Y, Z)`, where
`Z` extends `Y`, we incorrectly simplified `type[T] & <class 'Y'>` to
`type[T]`.

Both `Y` and `Z` instances are subtypes of `Y`, but only the class
object `Y` satisfies `klass is Y`. Using instance subtyping for the
exact class object discarded that information, causing `Y` itself to
widen to `type[T]` and `Y()` to be checked against `Z`'s constructor. We
now exclude exact class literals and specialized generic aliases from
that check.

We still retain this behavior when a type variable’s upper bound
normalizes to the exact target class object. This can only happen for a
final class, so that class object is the type variable’s only possible
specialization. (This removed ~10 ecosystem false-positives.)

Closes https://github.com/astral-sh/ty/issues/3074.
2026-06-18 10:43:10 +00:00
Charlie Marsh 13e4a58da8 [ty] Address intersection receiver review feedback (#25819)
## Summary

This follows up on [the post-merge
review](https://github.com/astral-sh/ruff/pull/25626#pullrequestreview-4466748160)
of #25626.

`functools.partial` now preserves the full intersection receiver when
delegating member lookup to its nominal `partial[T]` view. Bound-method
fallback still resets the receiver when lookup switches to the separate
underlying function object; the implementation and regression coverage
now make that distinction explicit.

This also parenthesizes compound bound-method receivers in displayed
types and clarifies and relocates the related intersection receiver
documentation and tests.
2026-06-10 06:37:31 -07:00
Charlie Marsh 0569f2c27b [ty] Preserve intersection receivers during attribute lookup (#25626)
## Summary

When looking up an attribute on an intersection, we search each positive
element independently. We previously also used that individual element
as the receiver when binding descriptors and `Self`, which meant we lost
constraints:

```python
def f(value: Intersection[A, B]):
    reveal_type(value.method())  # A, previously
    reveal_type(value.descriptor)  # A, previously
```

This change separates (1) the type whose members are searched from (2)
the receiver used to bind the resulting attribute. We continue searching
each intersection element independently, but bind descriptors and Self
using the full intersection:

```python
def f(value: Intersection[A, B]):
    reveal_type(value.method())  # A & B
    reveal_type(value.descriptor)  # A & B
```

Closes https://github.com/astral-sh/ty/issues/3565.

Closes https://github.com/astral-sh/ty/issues/3600.
2026-06-06 01:09:55 +00:00
ReginaldandJelle Zijlstra dc79edf868 [ty] Add missing-type-argument lint rule (#25617)
## Summary

Add a new lint that detects generic types used without explicit type
parameters in annotations (e.g. `list` instead of `list[int]`).
This is equivalent to mypy's `--disallow-any-generics` and pyright's
`reportMissingTypeArgument`.

Can be enabled via:
```
    [rules]
    missing-type-argument = "warn"
```
It skips classes where all type parameters have PEP 696 defaults.

This should fix the following issue in ty:
- https://github.com/astral-sh/ty/issues/2442

## Test Plan

Added tests covering stdlib generics, user-defined generics, PEP 696
defaults, dotted names, function signatures, base classes, and variable annotations.

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-06-05 13:07:10 -07:00
Alex Waygood 65d768e4e2 [ty] Merge same-file annotations if there is only a single line separating them (#24694) 2026-04-17 17:00:07 +01:00
David Peter 08629b4954 [ty] Migrate more mdtests to inline snapshots (#24687)
## Summary

Migrate another ~20 test suites to inline snapshots (Friday batch).
2026-04-17 11:49:09 +02:00
Alex Waygood 725fbb736d [ty] Use partially qualified names when reporting diagnostics regarding bad calls to methods (#24560) 2026-04-16 12:43:52 +00:00
Alex Waygood a00d29d720 [ty] Emit a diagnostic when attempting to inherit from a class with __init_subclass__ = None (#24543) 2026-04-12 13:38:38 +00:00
Alex Waygood e89f8ef295 [ty] Fix bad diagnostic range for incorrect implicit __init_subclass__ calls (#24541) 2026-04-10 14:27:13 +00:00
Alex Waygood a07f3cfc95 [ty] Add snapshots for __init_subclass__ diagnostics (#24539) 2026-04-10 13:32:28 +00:00
Dhruv Manilawala ce8f75f18d Add RegularCallableTypeOf and into_regular_callable in ty_extensions (#23909)
## Summary

fixes: https://github.com/astral-sh/ty/issues/3020

## Test Plan

Add a regression test case that currently fails on `main`.
2026-03-13 09:26:41 +05:30
Hugo 2b5d34f740 [ty] Add mdtest for staticmethod assigned in class body (#23330)
## Summary

Ref: https://github.com/astral-sh/ty/issues/2724

Adds an mdtest regression case for:
- `bar = staticmethod(foo)`
- `__call__ = staticmethod(foo)`

The test validates class and instance calls with empty, positional, and
keyword arguments.
2026-02-16 11:22:39 +01:00
David Peter e22fa4f14d [ty] Fix method calls on subclasses of Any (#23248)
## Summary

Another small win in terms of typing conformance. This should fix the
last remaining test in
[`specialtypes_any.py`](https://shark.fish/typing-conformance-report/specialtypes_any.html)

## Ecosystem

The new diagnostics look like true positives (in our current strict
interpretation of LSP checks)

## Test Plan

New Markdown test
2026-02-12 20:25:39 +01:00
David Peter fa56c1550d [ty] Fix bound method access on None (#23246)
## Summary

Just a small quick win that should fix the last remaining conformance
test in
[`specialtypes_none.py`](https://shark.fish/typing-conformance-report/specialtypes_none.html).

`types.FunctionType` has the following overloads for `__get__` to model
accessing functions on a class vs. on an instance:

```py
class FunctionType:
    @overload
    def __get__(self, instance: None, owner: type, /) -> FunctionType:
        """Return an attribute of instance, which is of type owner."""

    @overload
    def __get__(self, instance: object, owner: type | None = None, /) -> MethodType: ...
```

The `instance: None` sentinel of the descriptor protocol is problematic
when we're actually accessing something on an instance of type `None`.
Here, we simply add a special case to fix this. Also, instead of using
`Type::none(db)` as a sentinel in the Rust code, we now use
`Optional<Type<…>>` such that we can use the Rust `None` if we want to
call `__get__` on a non-instance.

Fixes https://github.com/astral-sh/ty/issues/737

## Ecosystem

Looks good. Some strange-looking new diagnostics because symbols were
inferred as `None` where users did not intend that (but no wrong
behavior of ty).

## Test Plan

Adapted existing tests.
2026-02-12 20:16:42 +01:00
Dex Devlon 2f64ef9c72 [ty] Include type parameters in generic callable display (#22435) 2026-01-13 17:29:08 +00:00
RasmusNygren fde7d72fbb [ty] Add diagnostics for __init_subclass__ argument mismatch (#22185) 2026-01-13 16:15:51 +00:00
Enric CalabuigandDouglas Creager 6e89e0abff [ty] Fix classmethod + contextmanager + Self (#22407)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

The test I've added illustrates the fix. Copying it here too:

```python
from contextlib import contextmanager
from typing import Iterator
from typing_extensions import Self

class Base:
    @classmethod
    @contextmanager
    def create(cls) -> Iterator[Self]:
        yield cls()

class Child(Base): ...

with Base.create() as base:
    reveal_type(base)  # revealed: Base (after the fix, None before)

with Child.create() as child:
    reveal_type(child)  # revealed: Child (after the fix, None before)
```

Full disclosure: I've used LLMs for this PR, but the result is
thoroughly reviewed by me before submitting. I'm excited about my first
Rust contribution to Astral tools and will address feedback quickly.

Related to https://github.com/astral-sh/ty/issues/2030, I am working on
a fix for the TypeVar case also reported in that issue (by me)

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->

Updated mdtests

---------

Co-authored-by: Douglas Creager <dcreager@dcreager.net>
2026-01-13 09:29:58 -05:00
Charlie Marsh acdda78189 [ty] Fix @staticmethod combined with other decorators incorrectly binding self (#22128)
## Summary

We already had `CallableTypeKind::ClassMethodLike` to track callables
that behave like `classmethods` (always bind the first argument). This
PR adds the symmetric `CallableTypeKind::StaticMethodLike` for callables
that behave like `staticmethods` (never bind `self`).

Closes https://github.com/astral-sh/ty/issues/2114.
2025-12-24 03:35:09 +00:00
Aria Desires ad3de4e488 [ty] Improve rendering of default values for function args (#22010)
## Summary

We're actually quite good at computing this but the main issue is just
that we compute it at the type-level and so wrap it in `Literal[...]`.
So just special-case the rendering of these to omit `Literal[...]` and
fallback to `...` in cases where the thing we'll show is probably
useless (i.e. `x: str = str`).

Fixes https://github.com/astral-sh/ty/issues/1882
2025-12-16 13:39:19 -05:00
Carl Meyer eeaaa8e9fe [ty] propagate classmethod-ness through decorators returning Callables (#21958)
Fixes https://github.com/astral-sh/ty/issues/1787

## Summary

Allow method decorators returning Callables to presumptively propagate
"classmethod-ness" in the same way that they already presumptively
propagate "function-like-ness". We can't actually be sure that this is
the case, based on the decorator's annotations, but (along with other
type checkers) we heuristically assume it to be the case for decorators
applied via decorator syntax.

## Test Plan

Added mdtest.
2025-12-16 09:16:40 -08:00
Alex Waygood bb464ed924 [ty] Use unqualified names for displays of TypeAliasTypes and unbound ParamSpecs/TypeVars (#21960) 2025-12-13 20:23:16 +00:00
Alex Waygood a722df6a73 [ty] Enable even more goto-definition on inlay hints (#21950)
## Summary

Working on py-fuzzer recently (AKA, a Python project!) reminded me how
cool our "inlay hint goto-definition feature" is. So this PR adds a
bunch more of that!

I also made a couple of other minor changes to type display. For
example, in the playground, this snippet:

```py
def f(): ...
reveal_type(f.__get__)
```

currently leads to this diagnostic:

```
Revealed type: `<method-wrapper `__get__` of `f`>` (revealed-type) [Ln 2, Col 13]
```

But the fact that we have backticks both around the type display and
inside the type display isn't _great_ there. This PR changes it to

```
Revealed type: `<method-wrapper '__get__' of function 'f'>` (revealed-type) [Ln 2, Col 13]
```

which avoids the nested-backticks issue in diagnostics, and is more
similar to our display for various other `Type` variants such as
class-literal types (`<class 'Foo'>`, etc., not ``<class `Foo`>``).

## Test Plan

inlay snapshots added; mdtests updated
2025-12-12 12:57:38 -05:00
Ibraheem Ahmed 29bf2cd201 [ty] Support implicit type of cls in signatures (#21771)
## Summary

Extends https://github.com/astral-sh/ruff/pull/20517 to support the
implicit type of `cls` in `@classmethod` signatures. Part of
https://github.com/astral-sh/ty/issues/159.
2025-12-10 16:56:20 -05:00
Carl Meyer 6b7adb0537 [ty] support PEP 613 type aliases (#21394)
Refs https://github.com/astral-sh/ty/issues/544

## Summary

Takes a more incremental approach to PEP 613 type alias support (vs
https://github.com/astral-sh/ruff/pull/20107). Instead of eagerly
inferring the RHS of a PEP 613 type alias as a type expression, infer it
as a value expression, just like we do for implicit type aliases, taking
advantage of the same support for e.g. unions and other type special
forms.

The main reason I'm following this path instead of the one in
https://github.com/astral-sh/ruff/pull/20107 is that we've realized that
people do sometimes use PEP 613 type aliases as values, not just as
types (because they are just a normal runtime assignment, unlike PEP 695
type aliases which create an opaque `TypeAliasType`).

This PR doesn't yet provide full support for recursive type aliases
(they don't panic, but they just fall back to `Unknown` at the recursion
point). This is future work.

## Test Plan

Added mdtests.

Many new ecosystem diagnostics, mostly because we
understand new types in lots of places.

Conformance suite changes are correct.

Performance regression is due to understanding lots of new
types; nothing we do in this PR is inherently expensive.
2025-11-20 17:59:35 -08:00
Alex Waygood 39f105bc4a [ty] Use "cannot" consistently over "can not" (#21255) 2025-11-03 10:38:20 -05:00
Alex Waygood 9bacd19c5a [ty] Fix lookup of __new__ on instances (#21147)
## Summary

We weren't correctly modeling it as a `staticmethod` in all cases,
leading us to incorrectly infer that the `cls` argument would be bound
if it was accessed on an instance (rather than the class object).

## Test Plan

Added mdtests that fail on `main`. The primer output also looks good!
2025-10-30 13:42:46 -04:00
Alex Waygood 1f8297cfe6 [ty] Improve error messages for unresolved attribute diagnostics (#20963)
## Summary

- Type checkers (and type-checker authors) think in terms of types, but
I think most Python users think in terms of values. Rather than saying
that a _type_ `X` "has no attribute `foo`" (which I think sounds strange
to many users), say that "an object of type `X` has no attribute `foo`"
- Special-case certain types so that the diagnostic messages read more
like normal English: rather than saying "Type `<class 'Foo'>` has no
attribute `bar`" or "Object of type `<class 'Foo'>` has no attribute
`bar`", just say "Class `Foo` has no attribute `bar`"

## Test Plan

Mdtests and snapshots updated
2025-10-19 10:58:25 +01:00
cafb96aa7a [ty] Sync vendored typeshed stubs (#20876)
Close and reopen this PR to trigger CI

---------

Co-authored-by: typeshedbot <>
Co-authored-by: David Peter <mail@david-peter.de>
2025-10-15 11:13:32 +02:00
David Peter 949a4f1c42 [ty] Simplify and fix CallableTypeOf[..] implementation (#20797)
## Summary

Simplify and fix the implementation of
`ty_extensions.CallableTypeOf[..]`.

closes https://github.com/astral-sh/ty/issues/1331

## Test Plan

Added regression test.
2025-10-10 12:04:37 +02:00