There is class A (in another package) that defines an abstract method my_abstract_method()
using the old way of defining an abstract class by setting __metaclass__ = ABCMeta
.
My class B is a subclass of A, and I would like B to inherit A's my_abstact_method()
, and require all subclasses of B to implement my_abstract_method()
How would I go about doing this?
Example:
from abc import abstractmethod, ABC, ABCMeta
class A(object):
__metaclass__ = ABCMeta
@abstractmethod
def my_abstract_method(self):
return
class B(A, metaclass=ABCMeta):
pass
B()
When executed, B() is created successfully.
How can I get B() to fail because the abstract method of A is not defined?