-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
bpo-46066: Deprecate kwargs syntax for TypedDict definitions #31126
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
Changes from 6 commits
0c12774
f3588ac
4d988a8
f21c30a
3f60fb0
033cf07
eea168f
15a7930
b9badea
a6a870c
8b113dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1389,11 +1389,19 @@ These are not used in annotations. They are building blocks for declaring types. | |||||
| ``Point2D.__optional_keys__``. | ||||||
| To allow using this feature with older versions of Python that do not | ||||||
| support :pep:`526`, ``TypedDict`` supports two additional equivalent | ||||||
| syntactic forms:: | ||||||
| syntactic forms. Firstly, using a literal :class:`dict` as the | ||||||
| second argument:: | ||||||
|
|
||||||
| Point2D = TypedDict('Point2D', x=int, y=int, label=str) | ||||||
| Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) | ||||||
|
|
||||||
| Secondly, using keyword arguments:: | ||||||
|
||||||
| Secondly, using keyword arguments:: | |
| Keyword arguments may also be used:: |
97littleleaf11 marked this conversation as resolved.
Show resolved
Hide resolved
97littleleaf11 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,2 @@ | ||||||
| Deprecate kwargs-based syntax for :class:`typing.TypedDict` definitions. | ||||||
| It was unsupported by type checkers. Patch by Jingchen Ye. | ||||||
|
||||||
| It was unsupported by type checkers. Patch by Jingchen Ye. | |
| Patch by Jingchen Ye. |
Pyright supports it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to give a short summary of why this change is being made. Maybe It had confusing semantics, and was largely unused.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest just writing "a
TypedDictmay be created using a functional form". This parallels https://docs.python.org/3.10/library/enum.html#functional-apiThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!