mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
[ty] Make tuple instantiations sound (#18987)
## Summary Ensure that we correctly infer calls such as `tuple((1, 2))`, `tuple(range(42))`, etc. Ensure that we emit errors on invalid calls such as `tuple[int, str]()`. ## Test Plan Mdtests
This commit is contained in:
parent
6802c4702f
commit
a50a993b9c
6 changed files with 105 additions and 19 deletions
|
@ -41,9 +41,7 @@ bar"""
|
|||
reveal_type(len(())) # revealed: Literal[0]
|
||||
reveal_type(len((1,))) # revealed: Literal[1]
|
||||
reveal_type(len((1, 2))) # revealed: Literal[2]
|
||||
|
||||
# TODO: Handle constructor calls
|
||||
reveal_type(len(tuple())) # revealed: int
|
||||
reveal_type(len(tuple())) # revealed: Literal[0]
|
||||
|
||||
# TODO: Handle star unpacks; Should be: Literal[0]
|
||||
reveal_type(len((*[],))) # revealed: Literal[1]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue