]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-105566: Deprecate unusual ways of creating `typing.NamedTuple` classes (#105609)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Wed, 14 Jun 2023 12:38:49 +0000 (13:38 +0100)
committerGitHub <noreply@github.com>
Wed, 14 Jun 2023 12:38:49 +0000 (13:38 +0100)
commitad56340b665c5d8ac1f318964f71697bba41acb7
tree85e07e09edb9ae29c96bcd4fcdf01b5378765f60
parentfc8037d84c5f886849a05ec993dd0f79a356d372
gh-105566: Deprecate unusual ways of creating `typing.NamedTuple` classes (#105609)

Deprecate creating a typing.NamedTuple class using keyword arguments to denote the fields (`NT = NamedTuple("NT", x=int, y=str)`). This will be disallowed in Python 3.15. Use the class-based syntax or the functional syntax instead.

Two methods of creating `NamedTuple` classes with 0 fields using the functional syntax are also deprecated, and will be disallowed in Python 3.15: `NT = NamedTuple("NT")` and `NT = NamedTuple("NT", None)`. To create a `NamedTuple` class with 0 fields, either use `class NT(NamedTuple): pass` or `NT = NamedTuple("NT", [])`.
Doc/library/typing.rst
Doc/whatsnew/3.13.rst
Lib/test/test_typing.py
Lib/typing.py
Misc/NEWS.d/next/Library/2023-06-09-20-34-23.gh-issue-105566.YxlGg1.rst [new file with mode: 0644]