-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
bpo-38191: Accept arbitrary keyword names in NamedTuple() and TypedDict(). #16222
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.
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.
LGTM. Thanks, Serhiy for working on this!
If I understand correctly, the next step is to use PEP570 notation on master, right?
Yes, and drop this ugly boilerplate code. |
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.
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", |
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.
"now accept"
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