Skip to content
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

gh-104786: Remove kwargs-based TypedDict creation #104891

Merged
merged 10 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 5 additions & 5 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1768,14 +1768,14 @@ These are not used in annotations. They are building blocks for declaring types.

assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')

To allow using this feature with older versions of Python that do not
support :pep:`526`, ``TypedDict`` supports an additional syntactic
form using a literal :class:`dict` as the second argument::
There is an alternative way to create a ``TypedDict``
using a literal :class:`dict` as the second argument::
tomasr8 marked this conversation as resolved.
Show resolved Hide resolved

Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})

The functional syntax should also be used when any of the keys are not valid
:ref:`identifiers <identifiers>`, for example because they are keywords or contain hyphens.
This functional syntax allows defining keys which are not valid
:ref:`identifiers <identifiers>`, for example because they are
keywords or contain hyphens.
Example::
tomasr8 marked this conversation as resolved.
Show resolved Hide resolved

# raises SyntaxError
Expand Down
1 change: 0 additions & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import re as stdlib_re # Avoid confusion with the typing.re namespace on <=3.11
import sys
import types
import warnings
from types import WrapperDescriptorType, MethodWrapperType, MethodDescriptorType, GenericAlias

from _typing import (
Expand Down