Repository navigation
Closed
Labels
3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
Description
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:
assignee = None
closed_at = <Date 2020-04-08.08:05:31.438>
created_at = <Date 2020-04-04.21:08:45.136>
labels = ['type-feature', 'library', '3.9']
title = 'Refactor typing.NamedTuple'
updated_at = <Date 2022-03-09.04:16:10.586>
user = 'https://github.com/serhiy-storchaka'bugs.python.org fields:
activity = <Date 2022-03-09.04:16:10.586>
actor = 'juliusgeo'
assignee = 'none'
closed = True
closed_date = <Date 2020-04-08.08:05:31.438>
closer = 'serhiy.storchaka'
components = ['Library (Lib)']
creation = <Date 2020-04-04.21:08:45.136>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 40185
keywords = ['patch']
message_count = 5.0
messages = ['365783', '365788', '365972', '375101', '375105']
nosy_count = 6.0
nosy_names = ['gvanrossum', 'python-dev', 'serhiy.storchaka', 'levkivskyi', 'xtreak', 'juliusgeo']
pr_nums = ['19371', '31679', '31779']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue40185'
versions = ['Python 3.9']Metadata
Metadata
Assignees
Labels
3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
Activity
serhiy-storchaka commentedon Apr 4, 2020
typing.NamedTuple is used in two ways.
In both cases it is not a real class. You cannot create an instance of NamedTuple or a subclass of NamedTuple. But it is implemented as a class, and help() shows methods and data descriptors for it, which are useless.
The proposed PR implements NamedTuple like a function. Implementation of the __mro_entries__ method allows to use it as a base in the class statement.
serhiy-storchaka commentedon Apr 4, 2020
See also bpo-40187.
serhiy-storchaka commentedon Apr 8, 2020
New changeset a2ec069 by Serhiy Storchaka in branch 'master':
bpo-40185: Refactor typing.NamedTuple (GH-19371)
a2ec069
tirkarthi commentedon Aug 10, 2020
This seems to have caused a test failure in astroid project. I am not sure if the fix needs to be done from their end probably relying on some implementation detail or from the patch itself. Feel free to ignore if it's a third-party only error.
Reproducer script : /tmp/namedtuple_astroid.py
Before this commit :
python /tmp/namedtuple_astroid.py
Instance of typing.NamedTuple
After this commit :
serhiy-storchaka commentedon Aug 10, 2020
So mod.body[-1].value is a call:
I do not know what Astroid does with this node, but seem the problem is in its infer() method.