[New-bugs-announce] [issue36591] Should be a typing.UserNamedTuple
Terry Davis
report at bugs.python.org
Wed Apr 10 17:19:33 EDT 2019
New submission from Terry Davis <terry.y.davis at gmail.com>:
There should be a builtin alias for `Type[NamedTuple]` so that library
authors user-supplied `NamedTuple`s can properly type-check their code.
Here's a code sample that causes an issue in my IDE (PyCharm)
********************************
from typing import NamedTuple, Type
def fun(NT: NamedTuple, fill):
# Complains that NamedTuple is not callable
nt = NT(*fill)
return nt
UserNamedTuple = Type[NamedTuple]
def fun(NT: UserNamedTuple, fill):
# No complaints
nt = NT(*fill)
return nt
********************************
This could just be an issue with PyCharm (I don't use mypy), but the
correct to annotate this is with a Type[NamedTuple], so I hope mypy
et. al. wouldn't this as a special case...
----------
components: Library (Lib)
messages: 339893
nosy: Terry Davis
priority: normal
severity: normal
status: open
title: Should be a typing.UserNamedTuple
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36591>
_______________________________________
More information about the New-bugs-announce
mailing list