Skip to content

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

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

serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:unpack-concrete-tuple-types

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

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

https://bugs.python.org/issue43224

@JelleZijlstra

Copy link
Copy Markdown
Member

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

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

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

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

mrahtz commented Apr 11, 2022

Copy link
Copy Markdown
Contributor

+1 to what @JelleZijlstra says.

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

6 participants