-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Deprecate keyword args syntax for TypedDict definition #90224
Comments
According to the docs: https://docs.python.org/3/library/typing.html?#typing.TypedDict, there are two additional equivalent syntax for TypedDict definition. Point2D = TypedDict('Point2D', x=int, y=int, label=str)
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) However, the former one is quite confusing since we have the I think we could discard the definition syntax using keyword args in the doc. |
This is not really just a doc issue then, is it? Maybe we should just deprecate the feature? |
I recommend opening an issue here: https://github.com/python/typing/issues/new/choose |
Just so that all the discussion related to this issue can be found in one place, here's a summary:
|
Go ahead and send a or to deprecate it.-- |
"PR" |
@guido, OP already has — Jelle and I have both reviewed and approved it :) |
This change has introduced deprecation warning in tests PYTHONWARNINGS=always ./python -Wall -X dev -m test.test_typing
........................................................................................................................................................................................................................s................................................................................................................................................................................................./home/karthikeyan/stuff/python/cpython/Lib/test/test_typing.py:4589: DeprecationWarning: The kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.
TypedDict('Emp', _fields={'name': str, 'id': int})
./home/karthikeyan/stuff/python/cpython/Lib/test/test_typing.py:4602: DeprecationWarning: The kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.
TypedDict('Hi', x=1)
........................................ Ran 451 tests in 0.105s OK (skipped=1) |
Thanks, I'll send a PR. |
To the contrary, the deprecated syntax caused issues for such keys. The syntax that isn't deprecated works fine, e.g. Point2D = TypedDict('Point2D', {'x': int, 'y': int, '$label$': str}) |
@gvanrossum Thanks for the quick response. I deleted my previous comment right after I posted it realizing I had entirely misread it as if the kwargs method was the one being retained. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: