-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
Feature or enhancement
Provide an option to choose a custom base class for abc.ABCMeta.
Pitch
In its current implementation, ABCMeta is hard-coded to inherit from type directly, forwarding calls to its __new__ member right to type.__new__. So what happens if I have another metaclass MyMeta that also adds functionality to __new__, and want to inherit from both? It seems to me that there's no way to get the behaviour of ABCMeta and MyMeta without calling both metaclasses' __new__ and thus invoking type.__new__ twice.
To my understanding, ABCMeta's extra features over type could be isolated into a standalone package that then could be used to enrich an existing metaclass:
def ABCMetaFactory(meta_type):
class AbstractifiedMeta(meta_type): ...
...
return AbstractifiedMeta
ABCMeta = ABCMetaFactory(type)As an exact use case, pybind11 defines its own metaclass (pybind11_type), but I haven't found a non-hackish way to make it work with ABCMeta for quite a while now.

