-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add initial support for new style TypeVar defaults (PEP 696) #17985
Add initial support for new style TypeVar defaults (PEP 696) #17985
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
class ClassTs2[*Ts = *tuple[int, ...]]: ... | ||
[builtins fixtures/tuple.pyi] | ||
|
||
[case testPEP695TypeParameterDefaultInvalid] |
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.
There are no invalid tests for functions, and I couldn't find code that would error for bad defaults on generic functions.
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.
Done in 5f8e69c with a small exception for when the TypeVar isn't used in the function signature. In that case the TypeVar isn't actually bound to the tvar_scope
. Fixing that would probably require a bit more work. Left it as a TODO
for now.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Add initial support for TypeVar defaults using the new syntax. Similar to the old syntax, it doesn't fully work yet for ParamSpec, TypeVarTuple and recursive TypeVar defaults.
Refs: #14851