mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🐞) `Protocol` not understood as an `ABCMeta`

Open KotlinIsland opened this issue 1 year ago • 0 comments

from abc import ABC, ABCMeta
from typing import Protocol

a: ABCMeta
a = Protocol  # erm, error: "type[type]" is not assignable to "type[ABCMeta]"
a = ABC

mypy in real life

class Interface(Protocol):
    def f(self):
        print("hi")

class Data(Interface, Enum):  # runtime error: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
    a = 1

KotlinIsland avatar Oct 16 '24 06:10 KotlinIsland