Skip to content

Unsupported type Type[...] error when instantiating NamedTuple from class variable #4300

Closed
@joshstaiger

Description

@joshstaiger

Run mypy 0.550 on the following code

from typing import NamedTuple, Type, cast

class A(NamedTuple): ...

A1: Type[A] = A  # no error
A2: Type[A] = A  # error: Unsupported type Type["A"]
A2()

def j(cls: Type[A]) -> None:  # error: Unsupported type Type["A"]
    cls()

class B(): ... # no error

B1: Type[B] = B
B1()

I see error: Unsupported type Type["A"] on the lines for A2 and def j, but not in other places, as indicated.

I'm probably hitting an edge case for NamedTuple here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions