It is a common practice to create subclasses of ABCMeta for your own abstract metaclasses when you also have other metaclass(es). It helps solving metaclass conflict error.
For example:
fromdjang.db.modelsimportModelBasefromabcimportABCMetaclassAbstractModel(ABCMeta, ModelBase): ...
Or any other existing metaclass.
But, mypy treats ABCMeta and AbstractModel differently:
fromabcimportABCMeta, abstractmethodfromtypingimportProtocolclassA: # OK, has @abstractmethod@abstractmethoddeff(self) ->None:
pass# Expected:classB(A): # E: Class a.B has abstract attributes "f" # N: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclasspassclassC(A, metaclass=ABCMeta): # OK, has ABCMeta as a metaclasspassclassCustomABC(ABCMeta):
pass# Unexpected:classD(A, metaclass=CustomABC): # E: Class a.D has abstract attributes "f" # N: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclasspass
I think that needs to be fixed.
It is a common practice to create subclasses of
ABCMetafor your own abstract metaclasses when you also have other metaclass(es). It helps solving metaclass conflict error.For example:
Or any other existing metaclass.
But, mypy treats
ABCMetaandAbstractModeldifferently:I think that needs to be fixed.