-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Support TypedDict update() with keyword arguments #6019
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
Comments
This adds support for these methods through additional plugin hooks: * `pop` * `setdefault` * `update` (positional argument only) * `__delitem__` These methods also work and don't need plugin support: * `copy` * `has_key` (Python 2 only) * `viewitems` (Python 2 only) * `viewkeys` (Python 2 only) * `viewvalues` (Python 2 only) The base signatures for all of these methods are defined in `mypy_extensions._TypedDict`, which is a stub-only class only used internally by mypy. It becomes the new fallback type of all TypedDicts. Fixes #3843. Fixes #3550. There's some possible follow-up work that I'm leaving to other PRs, such as optimizing hook lookup through dictionaries in the default plugin, documenting the supported methods, and `update` with keyword arguments (#6019).
I think this would need to be added as a specification of the standard. I do not see this as allowed anywhere, and currently the update method is annotated as accepting only a Perhaps this should be moved to the typing repo (or I guess CPython)? |
I don't think this would require a change to the spec. The spec is mostly silent on the
The CPython issue tracker should only be used for tracking changes to the typing.py runtime. Spec changes should go to the python/typing issue tracker. |
Things like
d.update(x=1, y=2)
should be accepted ifd
is a TypedDict and the keys and values are compatible.The text was updated successfully, but these errors were encountered: