summaryrefslogtreecommitdiffstats
path: root/Doc/library/typing.rst
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-06-14 14:58:41 (GMT)
committerGitHub <noreply@github.com>2023-06-14 14:58:41 (GMT)
commit7b1f0f204a785485de1daf9d26828a81953537e4 (patch)
tree6f11456f04444190aa5b2e3bf1cc5ff41f915575 /Doc/library/typing.rst
parentd32e8d6070057eb7ad0eb2f9d9f1efab38b2cff4 (diff)
downloadcpython-7b1f0f204a785485de1daf9d26828a81953537e4.zip
cpython-7b1f0f204a785485de1daf9d26828a81953537e4.tar.gz
cpython-7b1f0f204a785485de1daf9d26828a81953537e4.tar.bz2
gh-105570: Deprecate unusual ways of creating empty TypedDicts (#105780)
Deprecate two methods of creating typing.TypedDict classes with 0 fields using the functional syntax: `TD = TypedDict("TD")` and `TD = TypedDict("TD", None)`. Both will be disallowed in Python 3.15. To create a TypedDict class with 0 fields, either use `class TD(TypedDict): pass` or `TD = TypedDict("TD", {})`.
Diffstat (limited to 'Doc/library/typing.rst')
-rw-r--r--Doc/library/typing.rst8
1 files changed, 8 insertions, 0 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 31861a0..73555d5 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -2388,6 +2388,14 @@ These are not used in annotations. They are building blocks for declaring types.
.. versionchanged:: 3.13
Removed support for the keyword-argument method of creating ``TypedDict``\ s.
+ .. deprecated-removed:: 3.13 3.15
+ When using the functional syntax to create a TypedDict class, failing to
+ pass a value to the 'fields' parameter (``TD = TypedDict("TD")``) is
+ deprecated. Passing ``None`` to the 'fields' parameter
+ (``TD = TypedDict("TD", None)``) is also deprecated. Both will be
+ disallowed in Python 3.15. To create a TypedDict class with 0 fields,
+ use ``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.
+
Protocols
---------