Skip to content

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

Closed
serhiy-storchaka wants to merge 1 commit intopython:mainfrom
serhiy-storchaka:unpack-concrete-tuple-types
Closed

bpo-43224: Unpack concrete tuple types into a sequence of types#32030
serhiy-storchaka wants to merge 1 commit intopython:mainfrom
serhiy-storchaka:unpack-concrete-tuple-types

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