Here’s simple example of code:
class meta(type): pass
class Test(str, metaclass = meta): pass
When I run mypy on it (just from cli, without any flags or other additional setup) I’m seeing next output:
test.py:2: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc]
I know that similar error appears at runtime when metaclass of derived class is not a subtype of all parents metaclasses. But type(str) is type
, and my class meta
derived from type
, so I cannot understand what’s incorrect here.
Provided example isn’t working only with str
parent class. Mypy says everything is correct when inheriting from int
or float
.
So, how to get rid of such error message? Or it is just a mypy bug?