Skip to content
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

bpo-43224: Unpack concrete tuple types into a sequence of types #32030

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Mar 21, 2022

G[*tuple[int, str]] == G[int, str]

https://bugs.python.org/issue43224

@JelleZijlstra
Copy link
Member

I'd rather not do this for the reasons @mrahtz explained elsewhere.

Another point: what about Unpack[Annotated[tuple[int, str], "whatever"]]?

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

I don't think we should do this (see also @mrahtz's comment at #91162 (comment)):

  • It would make Unpack[tuple[int, str]] not the same as *tuple[int, str].
  • def f(*args: *tuple[int, str]) would end up with int in its __annotations__ because of the way we implemented * there.
  • For runtime users of typing, in my experience it's better to keep information around than to simplify. If we simplify, runtime introspection can't reconstruct what the user meant; if we don't simplify, tool authors can probably deal with it easily.

@mrahtz
Copy link
Contributor

mrahtz commented Apr 11, 2022

+1 to what @JelleZijlstra says.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants