This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author emontnemery
Recipients AlexWaygood, Spencer Brown, emontnemery, eric.smith, gvanrossum, kj
Date 2021-12-03.11:44:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638531875.32.0.4151754765.issue45972@roundup.psfhosted.org>
In-reply-to
Content
Maybe something like this:

diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 735d477db4..8de913d8db 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -1291,7 +1291,8 @@ These are not used in annotations. They are building blocks for declaring types.

 .. class:: NamedTuple

-   Typed version of :func:`collections.namedtuple`.
+   Typed version of :func:`collections.namedtuple`, annotated fields are passed
+   to an underlying `collections.namedtuple`.

    Usage::

@@ -1311,9 +1312,20 @@ These are not used in annotations. They are building blocks for declaring types.

       employee = Employee('Guido')
       assert employee.id == 3
+      assert employee == ('Guido', 3)

    Fields with a default value must come after any fields without a default.

+   Non-annotated fields will not be part of the `collections.namedtuple`::
+
+      class Employee(NamedTuple):
+          name = 'Guido'
+          id = 3
+
+      employee = Employee()
+      assert employee.id == 3
+      assert not employee  # Passes because the collections.namedtuple is empty
+
    The resulting class has an extra attribute ``__annotations__`` giving a
    dict that maps the field names to the field types.  (The field names are in
History
Date User Action Args
2021-12-03 11:44:35emontnemerysetrecipients: + emontnemery, gvanrossum, eric.smith, Spencer Brown, kj, AlexWaygood
2021-12-03 11:44:35emontnemerysetmessageid: <1638531875.32.0.4151754765.issue45972@roundup.psfhosted.org>
2021-12-03 11:44:35emontnemerylinkissue45972 messages
2021-12-03 11:44:35emontnemerycreate