Skip to content
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

PEP 696: Add further clarification and edge cases #2902

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Gobot1234
Copy link
Contributor

@Gobot1234 Gobot1234 commented Nov 23, 2022

@Gobot1234 Gobot1234 requested a review from JelleZijlstra as a code owner Nov 23, 2022
@Gobot1234 Gobot1234 force-pushed the TypeVar-defaults branch 2 times, most recently from ba19037 to b37c069 Compare Nov 23, 2022
pep-0696.rst Outdated Show resolved Hide resolved
pep-0696.rst Outdated Show resolved Hide resolved
pep-0696.rst Outdated Show resolved Hide resolved
Gobot1234 and others added 2 commits Nov 27, 2022
Co-authored-by: Eric Traut <eric@traut.com>
@CAM-Gerlach CAM-Gerlach requested a review from erictraut Nov 29, 2022
pep-0696.rst Outdated Show resolved Hide resolved
pep-0696.rst Outdated
''''
Currently ``TypeVarTuple``\s as defaults are not supported due to
:ref:`scoping-rules` not allowing usage of ``TypeVarLikes`` from outer
scopes and multiple ``TypeVarTuple``\s cannot appear in the same
Copy link
Contributor

@erictraut erictraut Nov 29, 2022

Choose a reason for hiding this comment

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

I think you mean to say that "TypeVarTuple's from outer scopes are not supported in default types". The scoping rules don't dictate this, but there are other good reasons to disallow this.

Also, I'm not sure what you mean by "multiple TypeVarTuples cannot appear in the same signature". Normally, "signature" refers to the parameter list of a function. Are you referring here to the type expression used for the default type? Why is it illegal for multiple TypeVarTuples to appear here? Is it legal for the same TypeVarTuple to appear multiple times, as in tuple[int, *Ts] | tuple[str, *Ts]?

Copy link
Contributor Author

@Gobot1234 Gobot1234 Dec 3, 2022

Choose a reason for hiding this comment

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

The scoping rules don't solely mean that they aren't allowed in defaults, it is also the combination that there aren't any cases where you can have a TypeVarTuple default to another and have be it resolved because you can't have

class Foo[*Ts, *Us = *Ts]: ...

or because you can't have defaults in functions.

Unless I'm missing something there aren't any cases where you can use a TypeVarTuple with a TypeVarTuple default so they should just be disallowed.

pep-0696.rst Outdated Show resolved Hide resolved
@Gobot1234 Gobot1234 requested review from erictraut and removed request for JelleZijlstra Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants