mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 19:41:34 +00:00
[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:
parent
5fb142374d
commit
d23826ce46
2 changed files with 31 additions and 0 deletions
|
|
@ -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]
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue