[ty] cache Type::is_redundant_with (#20477)

Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
Carl Meyer 2025-10-16 04:46:56 -07:00 committed by GitHub
parent 5fb142374d
commit d23826ce46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View file

@ -360,3 +360,14 @@ type X = tuple[X, int]
def _(x: X):
reveal_type(x is x) # revealed: bool
```
### Recursive invariant
```py
type X = dict[str, X]
type Y = X | str | dict[str, Y]
def _(y: Y):
if isinstance(y, dict):
reveal_type(y) # revealed: dict[str, X] | dict[str, Y]
```