I'm currently developping for python 2, and I'm trying to use abstract base classes to simulate interfaces. I have an interface, a base implementation of that interface and many subclasses that extend the base implementation. It looks like this:
class Interface(object):
__metaclass__ = ABCMeta
class IAudit(Interface):
@abstractproperty
def timestamp(self):
raise NotImplementedError()
@abstractproperty
def audit_type(self):
raise NotImplementedError()
class BaseAudit(IAudit):
def __init__(self, audit_type):
# init logic
pass
@property
def timestamp(self):
return self._timestamp
@property
def audit_type(self):
return self._audit_type
class ConcreteAudit(BaseAudit):
def __init__(self, audit_type):
# init logic
super(ConcreteAudit, self).__init__(audit_type)
pass
However PyCharm notifies me that ConcreteAudit
should implement all abstract methods. However, BaseAudit
(which is not specified as an abc) already implements those methods, and ConcreteAudit
is a subclass of BaseAudit
. Why is PyCharm warning me? Shouldn't it detect that IAudit
's contract is already implemented through BaseAudit
?