Add foundation for TypeVar defaults (PEP 696)#14872
Add foundation for TypeVar defaults (PEP 696)#14872JelleZijlstra merged 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
c3cc492 to
f63386b
Compare
This comment has been minimized.
This comment has been minimized.
f63386b to
f2f5810
Compare
This comment has been minimized.
This comment has been minimized.
f2f5810 to
ccc0eef
Compare
This comment has been minimized.
This comment has been minimized.
ccc0eef to
bca0afc
Compare
This comment has been minimized.
This comment has been minimized.
mypy/semanal.py
Outdated
| self.process_placeholder( | ||
| None, | ||
| "Self upper bound", | ||
| "Self upper bound or default", |
There was a problem hiding this comment.
Maybe better to have a separate message for the two cases?
There was a problem hiding this comment.
In this particular instance I believe it isn't even necessary to check it at all. For Self the default is always set to AnyType(TypeOfAny.from_omitted_generics) and thus can't include a placeholder. I've split the calls in process_typevar_declaration though.
Also noticed that I was missing these checks in process_paramspec_declaration and process_typevartuple_declaration which I added now.
This comment has been minimized.
This comment has been minimized.
e5d9c3c to
6d94f22
Compare
This comment has been minimized.
This comment has been minimized.
JelleZijlstra
left a comment
There was a problem hiding this comment.
Looks good, one suggestion
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
Thanks @JelleZijlstra! I'll take a closer look at my followup PR tomorrow. |
|
Done:
topic-pep-696
|
Start implementing PEP 696 TypeVar defaults. This PR
defaultparameter toTypeVarLikeExprandTypeVarLikeType.defaultparameter.default=>AnyType(TypeOfAny.from_omitted_generics).A followup PR will update the semantic analyzer and add basic tests for
TypeVar,ParamSpec, andTypeVarTuplecalls with adefaultargument. -> #14873Ref #14851