Skip to content

gh-91162: Disallow tuple[T][*anything] - #92255

Closed
mrahtz wants to merge 3 commits into
python:mainfrom
mrahtz:subst-fixes-1
Closed

gh-91162: Disallow tuple[T][*anything]#92255
mrahtz wants to merge 3 commits into
python:mainfrom
mrahtz:subst-fixes-1

Conversation

@mrahtz

Copy link
Copy Markdown
Contributor

We agreed in #91162 that unpacked type arguments should only be valid to generic aliases that can accept a variable number of arguments - that is, unpacked type arguments should only be valid to generic aliases with a TypeVarTuple in the type parameters.

@JelleZijlstra Could I ask you for review on this?

(This PR is based on #92249, so there are a couple of extra commits. See the latest commit for the one that's actually part of this PR. I think I should be able to effectively hide the changes from the extra commits once #92249 is merged - so we can start review on this PR now?)

@mrahtz

Copy link
Copy Markdown
ContributorAuthor

Oops, sorry - while implementing another PR, I realised this is probably going to conflict with something else we'll need to do in typing.py. Closing for now.

@mrahtzmrahtz closed this May 3, 2022
complexity to typing.py). This spec is currently being discussed at
https://github.com/python/cpython/issues/91162.
Note that not all the rules governing substitution behavior at runtime
is codified in PEPs; the source of truth for these tests is the tests

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.

Suggested change
iscodifiedinPEPs; thesourceoftruthforthesetestsisthetests
arecodifiedinPEPs; thesourceoftruthforthesetestsisthetests

Comment threadLib/typing.py
return f'ForwardRef({self.__forward_arg__!r}{module_repr})'


def _is_unpacked_type(x: Any) -> bool:

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.

Suggested change
def_is_unpacked_type(x: Any) ->bool:
def_is_unpacked_type(x: object) ->bool:

@mrahtz

Copy link
Copy Markdown
ContributorAuthor

Thanks for the quick review anyway Jelle :) I'll integrate those suggestions in the upcoming PR.

@mrahtz
mrahtz deleted the subst-fixes-1 branch May 8, 2022 11:02
Sign up for freeto 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.

3 participants

@mrahtz@JelleZijlstra@bedevere-bot