mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
[red-knot] Move tuple containing Never
tests (#17137)
Refer https://github.com/astral-sh/ruff/pull/17094#discussion_r2023682840
This commit is contained in:
parent
eb3e176309
commit
f63024843c
2 changed files with 5 additions and 15 deletions
|
@ -1,15 +0,0 @@
|
|||
# Tuple
|
||||
|
||||
## `Never`
|
||||
|
||||
If a tuple type contains a `Never` element, then it is eagerly simplified to `Never` which means
|
||||
that a tuple type containing `Never` is disjoint from any other tuple type.
|
||||
|
||||
```py
|
||||
from typing_extensions import Never
|
||||
|
||||
def _(x: tuple[Never], y: tuple[int, Never], z: tuple[Never, int]):
|
||||
reveal_type(x) # revealed: Never
|
||||
reveal_type(y) # revealed: Never
|
||||
reveal_type(z) # revealed: Never
|
||||
```
|
|
@ -19,6 +19,11 @@ static_assert(is_equivalent_to(Never, tuple[int, Never]))
|
|||
static_assert(is_equivalent_to(Never, tuple[int, Never, str]))
|
||||
static_assert(is_equivalent_to(Never, tuple[int, tuple[str, Never]]))
|
||||
static_assert(is_equivalent_to(Never, tuple[tuple[str, Never], int]))
|
||||
|
||||
def _(x: tuple[Never], y: tuple[int, Never], z: tuple[Never, int]):
|
||||
reveal_type(x) # revealed: Never
|
||||
reveal_type(y) # revealed: Never
|
||||
reveal_type(z) # revealed: Never
|
||||
```
|
||||
|
||||
The empty `tuple` is *not* equivalent to `Never`!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue