◐ Shell
clean mode source ↗

bpo-43224: Unpack concrete tuple types into a sequence of types by serhiy-storchaka · Pull Request #32030 · python/cpython

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

@JelleZijlstra

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

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

JelleZijlstra

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 mrahtz mannequin mentioned this pull request

Apr 11, 2022