Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
97littleleaf11 commented Feb 4, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
This comment was marked as resolved.
AlexWaygood commented Feb 4, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Surely this is a breaking change — even if type-checkers only understand the literal-dict assignment-based syntax, I'm not sure we can change the runtime behaviour like this without a deprecation period. |
97littleleaf11 commented Feb 4, 2022
Yeah, it changes the typing module. However I seldom see this syntax in real-world projects since we already have class based one. |
97littleleaf11 commented Feb 4, 2022
I am not really familiar with the cpython developing period. It's not a big deal since neither mypy nor other widely-used type checkers implement this feature and I barely see this syntax in real world projects. |
AlexWaygood commented Feb 4, 2022
I appreciate that — but given that this is a change to the stdlib, I think the standard deprecation policy probably still applies :) |
97littleleaf11 commented Feb 4, 2022
Thanks for pointing out! |
AlexWaygood commented Feb 4, 2022
For now, I think I would:
Here's an example of a previous PR deprecating features, that you could look to as an example: #23064 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Misc/NEWS.d/next/Library/2022-02-08-16-42-20.bpo-46066.m32Hl0.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: AlexWaygood <Alex.Waygood@Gmail.com>
Misc/ACKS Outdated
| Ka-Ping Yee | ||
| Chi Hsuan Yen | ||
| Jason Yeo | ||
| Jingchen Ye |
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.
It feels absurd to bring this up (sorry!!), but: I think "Jingchen Ye" should go before "Ka-Ping Yee", if we're keeping this list alphabetised.
AlexWaygood commented Feb 8, 2022
Also, it looks like there's some trailing whitespace in some of the documentation changes you've made, which is making the documentation-related tests fail -- could you possibly fix those issues? |
97littleleaf11 commented Feb 8, 2022
@AlexWaygood Thanks for your reviews! btw, it seems that CI reports wrong line number about the trailing whitespace. |
AlexWaygood commented Feb 8, 2022
No worries, it's a good PR!
Huh — no idea what might be causing that :) |
AlexWaygood left a comment
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.
LGTM
AlexWaygood commented Feb 9, 2022
As this is a deprecation of an existing feature, I think it probably warrants a mention in "What's New in Python 3.11". I think @JelleZijlstra is planning on doing a PR for that document mentioning a bunch of recent changes to |
AlexWaygood commented Feb 10, 2022
@gvanrossum, could we possibly get the full test suite run on this PR, please? :) |
gvanrossum left a comment
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 can't stand "firstly" and "secondly" for some reason. :-(
97littleleaf11 commented Feb 12, 2022
How about "The first one" and "The other one"? |
arhadthedev commented Feb 12, 2022
Probably, a bullet list will be better. Like this:
|
JelleZijlstra left a comment
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.
Here's a concrete wording suggestion that avoids "Firstly" and "Secondly"
Doc/library/typing.rst Outdated
| support :pep:`526`, ``TypedDict`` supports two additional equivalent | ||
| syntactic forms:: | ||
| syntactic forms. Firstly, using a literal :class:`dict` as the | ||
| second argument:: |
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 TypedDict may be created using a functional form". This parallels https://docs.python.org/3.10/library/enum.html#functional-api
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.
Thanks for this!
Doc/library/typing.rst Outdated
| Point2D = TypedDict('Point2D', x=int, y=int, label=str) | ||
| Point2D = TypedDict('Point2D',{'x': int, 'y': int, 'label': str}) | ||
| Secondly, using keyword arguments:: |
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.
| Secondly, using keyword arguments:: | |
| Keyword arguments may also be used:: |
gvanrossum commented Feb 12, 2022
I was just hoping to see “first“ and “second”. No “ly” needed, these are flat adverbs. |
Misc/NEWS.d/next/Library/2022-02-08-16-42-20.bpo-46066.m32Hl0.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum commented Feb 14, 2022
In a few days Jelle can likely merge this himself. :-) |
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum commented Feb 17, 2022
Congrats Jelle! |
AlexWaygood commented Feb 17, 2022
And congrats @97littleleaf11 on your first CPython contribution! |
Closespython/typing#981
https://bugs.python.org/issue46066