Issue 36591: Should be a typing.UserNamedTuple (original) (raw)
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...