mypy icon indicating copy to clipboard operation
mypy copied to clipboard

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

Open user202729 opened this issue 2 years ago • 1 comments

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]

user202729 avatar May 07 '24 23:05 user202729

Resolved in https://github.com/python/mypy/pull/21946

EmmanuelNiyonshuti avatar Sep 09 '26 11:09 EmmanuelNiyonshuti