Closed
Description
There's some quirk in the definition of TextSerializable
which causes mypy
to error when inheriting from it along with some other base class.
Minimal example:
from fancy_dataclass.serialize import TextFileSerializable
class Mixin:
pass
class A(TextFileSerializable):
pass
class B(Mixin, TextFileSerializable):
pass
Running mypy
(version 1.14.1), I get:
error: Definition of "_from_bytes" in base class "TextSerializable" is incompatible with definition in base class "BinaryFileSerializable" [misc]
error: Definition of "_to_bytes" in base class "TextSerializable" is incompatible with definition in base class "BinaryFileSerializable" [misc]
The error only occurs on B
, not A
. My guess is that the type: ignore
statement on TextFileSerializable
(suppressing the error about incompatible method definitions) carries over to simple inheritance but not multiple inheritance.
Not sure if this is a bug in mypy
or not, but ideally the method signatures could be fixed to be compatible.