-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Description
Description
I am trying to create a Struct that is also an abstract class and run into the metaclass conflict.
Here's an example:
import msgspec
import abc
class Base(msgspec.Struct, metaclass=abc.ABCMeta):
member: int
@abc.abstractmethod
def method(self) -> None:
pass
class Subclass(Base):
pass
a = Subclass(7)
When executing above code, I get
Traceback (most recent call last):
File "x.py", line 5, in <module>
class Base(msgspec.Struct, metaclass=abc.ABCMeta):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Also tried with not using the metaclass, but inherit Base from abc.ABC directly, with the same result.
crflynn
Metadata
Metadata
Assignees
Labels
No labels