8000 Better handling of Any/object in variadic generics by ilevkivskyi · Pull Request #18643 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Better handling of Any/object in variadic generics #18643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 12, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Check join is symmetric
  • Loading branch information
ilevkivskyi committed Feb 12, 2025
commit 93fe7f695897f7f3881c8a4921ba19dd9ec9a0fc
3 changes: 3 additions & 0 deletions test-data/unit/check-typevar-tuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -2594,8 +2594,11 @@ def join(x: T, y: T) -> T: ...
def test(xs: tuple[Unpack[Ts]], xsi: tuple[int, Unpack[Ts]]) -> None:
a: tuple[Any, ...]
reveal_type(join(xs, a)) # N: Revealed type is "builtins.tuple[Any, ...]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also try the opposite argument order (join(a, xs)) here and below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, added symmetric check for each pair.

reveal_type(join(a, xs)) # N: Revealed type is "builtins.tuple[Any, ...]"
aa: tuple[Unpack[tuple[Any, ...]]]
reveal_type(join( 463C xs, aa)) # N: Revealed type is "builtins.tuple[Any, ...]"
reveal_type(join(aa, xs)) # N: Revealed type is "builtins.tuple[Any, ...]"
ai: tuple[int, Unpack[tuple[Any, ...]]]
reveal_type(join(xsi, ai)) # N: Revealed type is "Tuple[builtins.int, Unpack[builtins.tuple[Any, ...]]]"
reveal_type(join(ai, xsi)) # N: Revealed type is "Tuple[builtins.int, Unpack[builtins.tuple[Any, ...]]]"
[builtins fixtures/tuple.pyi]
0