Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 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
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Unreleased

# Release 4.7.0 (unreleased)

- Align the implementation of `TypedDict` with the implementation in the
standard library on 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.
- Skip a problematic test on Python 3.12.0b1. The test fails on 3.12.0b1 due to
a bug in CPython, which will be fixed in 3.12.0b2. The
`typing_extensions` test suite now passes on 3.12.0b1.
Expand Down
12 changes: 12 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ Special typing primitives

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

.. versionchanged:: 4.7.0

``TypedDict`` is now a function rather than a class.
This brings the ``typing_extensions.TypedDict`` closer to the implementation
Comment thread
JelleZijlstra marked this conversation as resolved.
Outdated
of :py:mod:`typing.TypedDict` on Python 3.9 and higher.

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

Expand Down Expand Up @@ -611,6 +617,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 of :py:func:`typing.is_typeddict`.

.. 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