mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
[ty] Understand homogeneous tuple annotations (#17998)
This commit is contained in:
parent
f301931159
commit
55df9271ba
17 changed files with 196 additions and 104 deletions
|
@ -317,8 +317,7 @@ reveal_type(A() + b"foo") # revealed: A
|
|||
reveal_type(b"foo" + A()) # revealed: bytes
|
||||
|
||||
reveal_type(A() + ()) # revealed: A
|
||||
# TODO this should be `A`, since `tuple.__add__` doesn't support `A` instances
|
||||
reveal_type(() + A()) # revealed: @Todo(full tuple[...] support)
|
||||
reveal_type(() + A()) # revealed: A
|
||||
|
||||
literal_string_instance = "foo" * 1_000_000_000
|
||||
# the test is not testing what it's meant to be testing if this isn't a `LiteralString`:
|
||||
|
|
|
@ -17,6 +17,7 @@ def _(x: tuple[int, str], y: tuple[None, tuple[int]]):
|
|||
|
||||
```py
|
||||
def _(x: tuple[int, ...], y: tuple[str, ...]):
|
||||
reveal_type(x + y) # revealed: @Todo(full tuple[...] support)
|
||||
reveal_type(x + (1, 2)) # revealed: @Todo(full tuple[...] support)
|
||||
# TODO: should be `tuple[int | str, ...]`
|
||||
reveal_type(x + y) # revealed: tuple[int | Unknown, ...]
|
||||
reveal_type(x + (1, 2)) # revealed: tuple[int, ...]
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue