summaryrefslogtreecommitdiff
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2017-01-22 17:47:20 -0800
committerGuido van Rossum <guido@python.org>2017-01-22 17:47:20 -0800
commit95919c096ca74b6a28000193e1c502408a9f3e6c (patch)
tree446025c2377497ec33ad583ed23a5c326a94229e /Lib/typing.py
parentd7adfe129cadbd35916152dc014da9278e472760 (diff)
downloadcpython-git-95919c096ca74b6a28000193e1c502408a9f3e6c.tar.gz
Issue #28556: Allow defining methods in NamedTuple class syntax (#362)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index eb42c19a9c..c9e3417537 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -2000,6 +2000,10 @@ class NamedTupleMeta(type):
default_names=', '.join(defaults_dict.keys())))
nm_tpl.__new__.__defaults__ = tuple(defaults)
nm_tpl._field_defaults = defaults_dict
+ # update from user namespace without overriding special namedtuple attributes
+ for key in ns:
+ if not hasattr(nm_tpl, key):
+ setattr(nm_tpl, key, ns[key])
return nm_tpl