8000 Incorrect argument substitution on Unpack[tuple[...]] · Issue #118168 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Incorrect argument substitution on Unpack[tuple[...]] #118168

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

Closed
JelleZijlstra opened this issue Apr 23, 2024 · 1 comment
Closed

Incorrect argument substitution on Unpack[tuple[...]] #118168

JelleZijlstra opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
3.12 only security fixes 3.13 bugs and security fixes topic-typing type-bug An unexpected behavior, bug, or error

Comments

@JelleZijlstra
Copy link
Member
JelleZijlstra commented Apr 23, 2024

Bug report

Bug description:

In the code below, all of the prints should be equivalent:

from typing import Generic, Tuple, TypeVarTuple, Unpack

Ts = TypeVarTuple("Ts")

class Old(Generic[*Ts]): ...
class New[*Ts]: ...

PartOld = Old[int, *Ts]
print(PartOld[str])
print(PartOld[*tuple[str]])
print(PartOld[*Tuple[str]])
print(PartOld[Unpack[tuple[str]]])  # Old[int, typing.Unpack[tuple[str]]]
print(PartOld[Unpack[Tuple[str]]])

PartNew = New[int, *Ts]
print(PartNew[str])
print(PartNew[*tuple[str]])
print(PartNew[*Tuple[str]])
print(PartNew[Unpack[tuple[str]]])  # New[int, typing.Unpack[tuple[str]]]
print(PartNew[Unpack[Tuple[str]]])

However, the Unpack[tuple[]] variants print something different. This is because the implementation of Unpack doesn't deal correctly with builtin aliases. I'll send a PR.

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

macOS

Linked PRs

@JelleZijlstra JelleZijlstra added type-bug An unexpected behavior, bug, or error topic-typing 3.12 only security fixes 3.13 bugs and security fixes labels Apr 23, 2024
@JelleZijlstra JelleZijlstra self-assigned this Apr 23, 2024
JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this issue Apr 23, 2024
JelleZijlstra added a commit that referenced this issue Apr 23, 2024
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 23, 2024
…H-118169)

(cherry picked from commit d0b664e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this issue Apr 23, 2024
) (#118178)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@nineteendo
Copy link
Contributor

It looks like you forgot to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants
0