mirror of https://github.com/astral-sh/ruff
[red-knot] Minor fixes in intersection-types tests (#15410)
## Summary Minor fixes in intersection-types tests
This commit is contained in:
parent
232fbc1300
commit
398f2e8b0c
|
|
@ -105,10 +105,10 @@ static_assert(not is_subtype_of(B2, B1))
|
||||||
This section covers structural properties of intersection types and documents some decisions on how
|
This section covers structural properties of intersection types and documents some decisions on how
|
||||||
to represent mixtures of intersections and unions.
|
to represent mixtures of intersections and unions.
|
||||||
|
|
||||||
### Single-element unions
|
### Single-element intersections
|
||||||
|
|
||||||
If we have a union of a single element, we can simplify to that element. Similarly, we show an
|
If we have an intersection with a single element, we can simplify to that element. Similarly, we
|
||||||
intersection with a single negative contribution as just the negation of that element.
|
show an intersection with a single negative contribution as just the negation of that element.
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from knot_extensions import Intersection, Not
|
from knot_extensions import Intersection, Not
|
||||||
|
|
@ -422,8 +422,8 @@ def example_type_bool_type_str(
|
||||||
|
|
||||||
#### Positive and negative contributions
|
#### Positive and negative contributions
|
||||||
|
|
||||||
If we intersect a type `X` with the negation of a disjoint type `Y`, we can remove the negative
|
If we intersect a type `X` with the negation `~Y` of a disjoint type `Y`, we can remove the negative
|
||||||
contribution `~Y`, as it necessarily overlaps with the positive contribution `X`:
|
contribution `~Y`, as `~Y` must fully contain the positive contribution `X` as a subtype:
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from knot_extensions import Intersection, Not
|
from knot_extensions import Intersection, Not
|
||||||
|
|
@ -515,8 +515,7 @@ def _(
|
||||||
|
|
||||||
#### Negative type and negative subtype
|
#### Negative type and negative subtype
|
||||||
|
|
||||||
For negative contributions, this property is reversed. Here we can get remove superfluous
|
For negative contributions, this property is reversed. Here we can remove superfluous _subtypes_:
|
||||||
_subtypes_:
|
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from knot_extensions import Intersection, Not
|
from knot_extensions import Intersection, Not
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue