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
base: main
Are you sure you want to change the base?
Conversation
ba19037
to
b37c069
Compare
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 |
There was a problem hiding this comment.
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]?
There was a problem hiding this comment.
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.
cc @erictraut