Skip to content

Literal[⟨enum⟩] not callable even if enum is callable #17222

Open
@user202729

Description

@user202729

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.12&gist=7a3708ec5466904d85b33bc6196c0db9

Code copied here:

import enum
import typing

class A(enum.Enum):
    a = 1
    b = 2
    def __call__(self)->int: return 2

x=A.a
print(x())  # okay
if x==A.a:
    print(x())  # error???

Expected Behavior

No error happen

Actual Behavior

error: "Literal[A.a]" not callable  [misc]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions