Skip to content

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

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

Closed
wants to merge 3 commits into from
Closed

Conversation

mrahtz
Copy link
Contributor

@mrahtz mrahtz commented May 3, 2022

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
Contributor Author

mrahtz commented May 3, 2022

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.

@mrahtz mrahtz 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
Member

Choose a reason for hiding this comment

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

Suggested change
is codified in PEPs; the source of truth for these tests is the tests
are codified in PEPs; the source of truth for these tests is the tests

@@ -876,6 +876,15 @@ def __repr__(self):
return f'ForwardRef({self.__forward_arg__!r}{module_repr})'


def _is_unpacked_type(x: Any) -> bool:
Copy link
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
Contributor Author

mrahtz commented May 3, 2022

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 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.

3 participants