Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Unreleased

- Declare support for Python 3.12. Patch by Jelle Zijlstra.
- Fix tests on Python 3.13, which removes support for creating
`TypedDict` classes through the keyword-argument syntax. Patch by
Jelle Zijlstra.

# Release 4.6.3 (June 1, 2023)

Expand Down
7 changes: 7 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ Special typing primitives
``typing_extensions`` backport provides all of these features and bugfixes on
all Python versions.

Historically, ``TypedDict`` has supported an alternative creation syntax
where the fields are supplied as keyword arguments (e.g.,
``TypedDict("TD", a=int, b=str)``). In CPython, this feature was deprecated
in Python 3.11 and removed in Python 3.13. ``typing_extensions.TypedDict``
raises a :py:exc:`DeprecationWarning` when this syntax is used in Python 3.12
or lower and fails with a :py:exc:`TypeError` in Python 3.13 and higher.

.. versionchanged:: 4.3.0

Added support for generic ``TypedDict``\ s.
Expand Down
7 changes: 7 additions & 0 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,12 @@ def test_basics_iterable_syntax(self):
self.assertEqual(Emp.__annotations__, {'name': str, 'id': int})
self.assertEqual(Emp.__total__, True)

@skipIf(sys.version_info < (3, 13), "Change in behavior in 3.13")
def test_keywords_syntax_raises_on_3_13(self):
with self.assertRaises(TypeError):
Emp = TypedDict('Emp', name=str, id=int)

@skipIf(sys.version_info >= (3, 13), "3.13 removes support for kwargs")
def test_basics_keywords_syntax(self):
with self.assertWarns(DeprecationWarning):
Emp = TypedDict('Emp', name=str, id=int)
Expand All @@ -2895,6 +2901,7 @@ def test_basics_keywords_syntax(self):
self.assertEqual(Emp.__annotations__, {'name': str, 'id': int})
self.assertEqual(Emp.__total__, True)

@skipIf(sys.version_info >= (3, 13), "3.13 removes support for kwargs")
def test_typeddict_special_keyword_names(self):
with self.assertWarns(DeprecationWarning):
TD = TypedDict("TD", cls=type, self=object, typename=str, _typename=int,
Expand Down