bpo-38191: Accept arbitrary keyword names in NamedTuple() and TypedDict().#16222
Conversation
…ct(). This includes such names as "cls", "self", "typename", "_typename", "fields" and "_fields". Passing positional arguments by keyword is deprecated.
|
Yes, and drop this ugly boilerplate code. |
gvanrossum
left a comment
There was a problem hiding this comment.
What deprecation schedule do you propose? Can we start using '/' in 3.9? In 3.8?
@ilevkivskyi Maybe this version should be upstreamed (downstreamed?) to github.com/python/typing?
| @@ -0,0 +1,4 @@ | |||
| Constructors of :class:`~typing.NamedTuple` and :class:`~typing.TypedDict` | |||
| types accept now arbitrary keyword argument names, including "cls", "self", | |||
|
3.7 -- no deprecation (but arbitrary keywords supported) I think a chance to break somebody's code is small, so we can use a short deprecation period. But there is still a risk, and we do not want to break working code at this stage of 3.8. |
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8. |
…ct(). (pythonGH-16222) This includes such names as "cls", "self", "typename", "_typename", "fields" and "_fields". Passing positional arguments by keyword is deprecated. (cherry picked from commit 2bf31cc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-16237 is a backport of this pull request to the 3.8 branch. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
…ypedDict(). (pythonGH-16222) This includes such names as "cls", "self", "typename", "_typename", "fields" and "_fields". Passing positional arguments by keyword is deprecated.. (cherry picked from commit 2bf31cc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-16239 is a backport of this pull request to the 3.7 branch. |
Yes, I think so. Also probably the signatures in typeshed should be updated. |
I'm not sure -- are those signatures even used, given the special-casing of TypedDict and NamedTuple? |
Mypy only uses signature of |
Fixes #677 This backports python/cpython#16222 (Python 3 only). The Python 2 backport is more tricky so I skip it for now.
Fixes python/typing#677 This backports python/cpython#16222 (Python 3 only). The Python 2 backport is more tricky so I skip it for now.
Fixes python/typing#677 This backports python/cpython#16222 (Python 3 only). The Python 2 backport is more tricky so I skip it for now.
This includes such names as "cls", "self", "typename", "_typename",
"fields" and "_fields".
Passing positional arguments by keyword is deprecated.
https://bugs.python.org/issue38191