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.

classification
Title: Should be a typing.UserNamedTuple
Type: enhancement Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: levkivskyi Nosy List: Terry Davis, levkivskyi
Priority: normal Keywords:

Created on 2019-04-10 21:19 by Terry Davis, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg339893 - (view) Author: Terry Davis (Terry Davis) Date: 2019-04-10 21:19
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...
msg340054 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2019-04-12 15:00
This is a duplicate of https://github.com/python/typing/issues/431

We can of course close the other issue and keep this one open, but the other one has much more discussion. So I am closing this one.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80772
2019-04-12 15:00:21levkivskyisetstatus: open -> closed
resolution: duplicate
messages: + msg340054

stage: resolved
2019-04-12 05:06:53rhettingersetassignee: levkivskyi

nosy: + levkivskyi
2019-04-10 21:19:33Terry Daviscreate