Skip to content

Enum of a NamedTuple-derived type leads to incompatible type error #1745

Closed
@alexsydell

Description

@alexsydell

This code:

from typing import NamedTuple
from enum import Enum

Foo = NamedTuple('Foo', [('bar', int)])

class MyEnum(Foo, Enum):
    CONSTANT = Foo(bar=1)

def f(x):
    # type: (MyEnum) -> None
    pass

f(MyEnum.CONSTANT)

leads to:

error: Argument 1 to "f" has incompatible type "test.MyEnum"; expected "MyEnum"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions