PEP 692: Add changing the meaning of `**kwargs` annotations to rejected ideas (#2916)

This commit is contained in:
Jelle Zijlstra 2022-12-07 11:49:09 -08:00 committed by GitHub
parent 53cdf55b7d
commit a73c0e9750
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -589,6 +589,21 @@ overloaded::
@overload @overload
def foo(**kwargs: **Book): ... def foo(**kwargs: **Book): ...
Changing the meaning of ``**kwargs`` annotations
------------------------------------------------
One way to achieve the purpose of this PEP without any grammar
change would be to change the meaning of ``**kwargs`` annotations,
so that the annotations would apply to the entire ``**kwargs`` dict,
not to individual elements. For consistency, we would have to make an
analogous change to ``*args`` annotations.
This idea was discussed in a meeting of the typing community, and the
consensus was that the change would not be worth the cost. There is no
clear migration path, the current meaning of ``*args`` and ``**kwargs``
annotations is well-established in the ecosystem, and type checkers
would have to introduce new errors for code that is currently legal.
References References
========== ==========