msg408458 - (view) |
Author: 97littleleaf11 (97littleleaf11) * |
Date: 2021-12-13 15:36 |
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 `total` keyword arg for TypedDict. In addition, PEP589(https://www.python.org/dev/peps/pep-0589/#id19) doesn't have this. I think we could discard the definition syntax using keyword args in the doc. |
|
|
msg408476 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2021-12-13 19:47 |
This is not really just a doc issue then, is it? Maybe we should just deprecate the feature? |
|
|
msg408547 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2021-12-14 16:43 |
I recommend opening an issue here: https://github.com/python/typing/issues/new/choose |
|
|
msg412990 - (view) |
Author: Alex Waygood (AlexWaygood) *  |
Date: 2022-02-10 10:48 |
Just so that all the discussion related to this issue can be found in one place, here's a summary: - After opening this ticket, OP opened an issue in the python/typing repository, where the idea of deprecating this syntax received many thumbs-up reactions, and where there were no dissenting voices: https://github.com/python/typing/issues/981 - The initial impetus for this change was this mypy bug report: https://github.com/python/mypy/issues/11555 - Mypy's policy since January 2020 has been that it would be more trouble than it's worth to attempt to support the kwargs-based syntax: https://github.com/python/mypy/issues/2492#issuecomment-579500959 |
|
|
msg413013 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2022-02-10 17:22 |
Go ahead and send a or to deprecate it.-- --Guido (mobile) |
|
|
msg413014 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2022-02-10 17:31 |
"PR" |
|
|
msg413016 - (view) |
Author: Alex Waygood (AlexWaygood) *  |
Date: 2022-02-10 17:34 |
@Guido, OP already has — Jelle and I have both reviewed and approved it :) |
|
|
msg413379 - (view) |
Author: Jelle Zijlstra (JelleZijlstra) *  |
Date: 2022-02-17 03:26 |
New changeset de6043e596492201cc1a1eb28038970bb69f3107 by 97littleleaf11 in branch 'main': bpo-46066: Deprecate kwargs syntax for TypedDict definitions (GH-31126) https://github.com/python/cpython/commit/de6043e596492201cc1a1eb28038970bb69f3107 |
|
|
msg413531 - (view) |
Author: Karthikeyan Singaravelan (xtreak) *  |
Date: 2022-02-19 05:25 |
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) |
|
|
msg413535 - (view) |
Author: Jelle Zijlstra (JelleZijlstra) *  |
Date: 2022-02-19 05:57 |
Thanks, I'll send a PR. |
|
|
msg413562 - (view) |
Author: Jelle Zijlstra (JelleZijlstra) *  |
Date: 2022-02-20 01:44 |
New changeset 0a8a8e7454c6565cf1554d5f23314e4c70960bcd by Jelle Zijlstra in branch 'main': bpo-46066: Check DeprecationWarning in test_typing (GH-31428) https://github.com/python/cpython/commit/0a8a8e7454c6565cf1554d5f23314e4c70960bcd |
|
|