Skip to content

Commit ffca69f

Browse files
committed
Move tests to annotations/tuple.md
1 parent cc99763 commit ffca69f

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tuple
2+
3+
## `Never`
4+
5+
If a tuple type contains a `Never` element, then it is eagerly simplified to `Never` which means
6+
that a tuple type containing `Never` is disjoint from any other tuple type.
7+
8+
```py
9+
def _(x: tuple[Never], y: tuple[int, Never], z: tuple[Never, int]):
10+
reveal_type(x) # revealed: Never
11+
reveal_type(y) # revealed: Never
12+
reveal_type(z) # revealed: Never
13+
```

crates/red_knot_python_semantic/resources/mdtest/type_properties/is_disjoint_from.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@ static_assert(is_disjoint_from(tuple[Literal[1], Literal[2]], tuple[Literal[1],
8080
static_assert(not is_disjoint_from(tuple[Literal[1], Literal[2]], tuple[Literal[1], int]))
8181
```
8282

83-
If a tuple type contains a `Never` element, then it is eagerly simplified to `Never` which means
84-
that a tuple type containing `Never` is disjoint from any other tuple type.
85-
86-
```py
87-
def _(x: tuple[Never], y: tuple[int, Never], z: tuple[Never, int]):
88-
reveal_type(x) # revealed: Never
89-
reveal_type(y) # revealed: Never
90-
reveal_type(z) # revealed: Never
91-
```
92-
9383
## Unions
9484

9585
```py
@@ -366,8 +356,10 @@ static_assert(is_disjoint_from(type[UsesMeta1], type[UsesMeta2]))
366356

367357
## Callables
368358

369-
No two callable types are disjoint because there exists a callable type
359+
No two callable types are disjoint because there exists a non-empty callable type
370360
`(*args: object, **kwargs: object) -> Never` that is a subtype of all fully static callable types.
361+
As such, for any two callable types, it is possible to conceive of a runtime callable object that would
362+
inhabit both types simultaneously.
371363

372364
```py
373365
from knot_extensions import CallableTypeOf, is_disjoint_from, static_assert

0 commit comments

Comments
 (0)