Skip to content

Mypy does not detect metaclass conflicts #13563

Description

@sobolevn

Minimal reproducer:

classMyMeta1(type): ...
classMyMeta2(type): ...
classA(metaclass=MyMeta1): ...
classB(metaclass=MyMeta2): ...
classC(A, B): ...

In runtime it causes:

» pythonex.pyTraceback (mostrecentcalllast):
File"ex.py", line5, in<module>classC(A, B): ...
TypeError: metaclassconflict: themetaclassofaderivedclassmustbea (non-strict) subclassofthemetaclassesofallitsbases

But, mypy is fine with it:

» mypyex.py--strictSuccess: noissuesfoundin1sourcefile

Important note: I think this should only work outside of stubs, because we do some extra metaclass hackery (like ABCMeta) in stubs. Moreover, in stubs - it won't raise.

Related #13561

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions