[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:
Alex Waygood 2025-06-27 19:37:16 +01:00 committed by GitHub
parent 6802c4702f
commit a50a993b9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 105 additions and 19 deletions

View file

@ -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]