Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Release 4.7.0 (unreleased)

- Align the implementation of `TypedDict` with that in Python 3.9 and higher.
`typing_extensions.TypedDict` is now a function instead of a class. The
private functions `_check_fails`, `_dict_new`, and `_typeddict_new`
have been removed. `is_typeddict` now returns `False` when called with
`TypedDict` itself as the argument. Patch by Jelle Zijlstra.

# Release 4.6.2 (May 25, 2023)

- Fix use of `@deprecated` on classes with `__new__` but no `__init__`.
Expand Down
11 changes: 11 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ Special typing primitives

Support for the ``__orig_bases__`` attribute was added.

.. versionchanged:: 4.7.0

The implementation of ``TypedDict`` now follows that in Python 3.9 and higher,
where ``TypedDict`` is a function rather than a class.

.. class:: TypeVar(name, *constraints, bound=None, covariant=False,
contravariant=False, infer_variance=False, default=...)

Expand Down Expand Up @@ -611,6 +616,12 @@ Functions

.. versionadded:: 4.1.0

.. versionchanged:: 4.7.0

:func:`is_typeddict` now returns ``False`` when called with
:data:`TypedDict` itself as the argument, consistent with the
behavior in :mod:`typing`.

.. function:: reveal_type(obj)

See :py:func:`typing.reveal_type`. In ``typing`` since 3.11.
Expand Down
6 changes: 5 additions & 1 deletion src/_typed_dict_test_helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from typing import Generic, Optional, T
from typing_extensions import TypedDict
from typing_extensions import TypedDict, Annotated, Required


# this class must not be imported into test_typing_extensions.py at top level, otherwise
Expand All @@ -16,3 +16,7 @@ class Foo(TypedDict):

class FooGeneric(TypedDict, Generic[T]):
a: Optional[T]


class VeryAnnotated(TypedDict, total=False):
a: Annotated[Annotated[Annotated[Required[int], "a"], "b"], "c"]
Loading