mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:34:57 +00:00
[ty] detect cycles in Type::is_disjoint_from (#19139)
This commit is contained in:
parent
7712c2fd15
commit
411cccb35e
7 changed files with 129 additions and 52 deletions
|
@ -1862,6 +1862,21 @@ class Bar(Protocol):
|
|||
static_assert(is_equivalent_to(Foo, Bar))
|
||||
```
|
||||
|
||||
### Disjointness of recursive protocol and recursive final type
|
||||
|
||||
```py
|
||||
from typing import Protocol
|
||||
from ty_extensions import is_disjoint_from, static_assert
|
||||
|
||||
class Proto(Protocol):
|
||||
x: "Proto"
|
||||
|
||||
class Nominal:
|
||||
x: "Nominal"
|
||||
|
||||
static_assert(not is_disjoint_from(Proto, Nominal))
|
||||
```
|
||||
|
||||
### Regression test: narrowing with self-referential protocols
|
||||
|
||||
This snippet caused us to panic on an early version of the implementation for protocols.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue