[Python-ideas] Abstract metaclasses?

Ethan Furman ethan at stoneleaf.us
Thu Sep 11 01:10:26 CEST 2014


On 09/10/2014 04:00 PM, Erik Bray wrote:
> On Wed, Sep 10, 2014 at 6:29 PM, Ethan Furman wrote:
>>
>> If that is what you want you should use `abstractclassmethod`.
>
> That would be fine if the classmethods were being defined in a normal
> class.  And with a little rearchitecting maybe that would be a simpler
> workaround for my own issues.  But I still think this should work
> properly for methods belonging to a metaclass.

Ah, right -- any method defined on a metaclass is a defacto class method.


> For that matter, I feel like this is a bug too:
>
> --> class Foo(metaclass=abc.ABCMeta):
> ...     @classmethod
> ...     @abc.abstractmethod
> ...     def my_classmethod(cls): pass
> ...
> --> class FooSub(Foo):
> ...     def my_classmethod(self):
> ...         pass  # Not actually a classmethod
> ...
> -> FooSub()

You'll have to search the docs, bug-tracker, and mailing lists for that one -- I do seem to remember reading about it, 
but don't recall where.

--
~Ethan~


More information about the Python-ideas mailing list