Issue 46066: Deprecate keyword args syntax for TypedDict definition
Created on 2021-12-13 15:36 by 97littleleaf11, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 31126 | merged | 97littleleaf11, 2022-02-04 07:55 | |
| PR 31428 | merged | JelleZijlstra, 2022-02-19 06:02 | |
| Messages (11) | |||
|---|---|---|---|
| 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 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:53 | admin | set | github: 90224 |
| 2022-02-20 01:44:58 | JelleZijlstra | set | messages: + msg413562 |
| 2022-02-19 06:02:02 | JelleZijlstra | set | pull_requests: + pull_request29563 |
| 2022-02-19 05:57:51 | JelleZijlstra | set | messages: + msg413535 |
| 2022-02-19 05:25:14 | xtreak | set | nosy:
+ xtreak messages: + msg413531 |
| 2022-02-17 03:26:40 | JelleZijlstra | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2022-02-17 03:26:17 | JelleZijlstra | set | messages: + msg413379 |
| 2022-02-10 17:34:52 | AlexWaygood | set | messages: + msg413016 |
| 2022-02-10 17:31:40 | gvanrossum | set | messages: + msg413014 |
| 2022-02-10 17:22:25 | gvanrossum | set | messages: + msg413013 |
| 2022-02-10 10:48:23 | AlexWaygood | set | messages: + msg412990 |
| 2022-02-08 09:05:18 | AlexWaygood | set | nosy:
- docs@python title: Remove keyword args syntax for TypedDict definition -> Deprecate keyword args syntax for TypedDict definition assignee: docs@python -> versions: + Python 3.11, - Python 3.8, Python 3.9, Python 3.10 components: + Library (Lib), - Documentation type: behavior |
| 2022-02-04 12:24:59 | AlexWaygood | set | nosy:
+ JelleZijlstra, sobolevn, AlexWaygood |
| 2022-02-04 07:55:58 | 97littleleaf11 | set | keywords:
+ patch stage: patch review pull_requests: + pull_request29305 |
| 2022-02-04 07:52:56 | 97littleleaf11 | set | title: TypedDict alternative definition syntax with keyword args is confusing -> Remove keyword args syntax for TypedDict definition |
| 2021-12-14 16:43:02 | gvanrossum | set | messages: + msg408547 |
| 2021-12-14 12:39:01 | 97littleleaf11 | set | title: [doc] TypedDict alternative definition syntax with keyword args is confusing -> TypedDict alternative definition syntax with keyword args is confusing |
| 2021-12-13 19:47:07 | gvanrossum | set | messages: + msg408476 |
| 2021-12-13 17:36:57 | AlexWaygood | set | nosy:
+ gvanrossum, kj |
| 2021-12-13 15:38:08 | 97littleleaf11 | set | title: Docs: TypedDict alternative definition syntax with keyword args is confusing -> [doc] TypedDict alternative definition syntax with keyword args is confusing |
| 2021-12-13 15:36:57 | 97littleleaf11 | create | |

