Charlie Marsh
68a2f6c57d
[ty] Fix super() with TypeVar-annotated self and cls parameter ( #22208 )
...
## Summary
This PR fixes `super()` handling when the first parameter (`self` or
`cls`) is annotated with a TypeVar, like `Self`.
Previously, `super()` would incorrectly resolve TypeVars to their bounds
before creating the `BoundSuperType`. So if you had `self: Self` where
`Self` is bounded by `Parent`, we'd process `Parent` as a
`NominalInstance` and end up with `SuperOwnerKind::Instance(Parent)`.
As a result:
```python
class Parent:
@classmethod
def create(cls) -> Self:
return cls()
class Child(Parent):
@classmethod
def create(cls) -> Self:
return super().create() # Error: Argument type `Self@create` does not satisfy upper bound `Parent`
```
We now track two additional variants on `SuperOwnerKind` for TypeVar
owners:
- `InstanceTypeVar`: for instance methods where self is a TypeVar (e.g.,
`self: Self`).
- `ClassTypeVar`: for classmethods where `cls` is a `TypeVar` wrapped in
`type[...]` (e.g., `cls: type[Self]`).
Closes https://github.com/astral-sh/ty/issues/2122 .
---------
Co-authored-by: Carl Meyer <carl@astral.sh >
2026-01-07 19:56:09 -05:00
..
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-07 13:22:53 +00:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-06 04:14:06 +00:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-07 19:56:09 -05:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-06 20:01:41 +00:00
2026-01-06 20:01:41 +00:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 11:28:04 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00
2026-01-05 07:55:47 -08:00