Closed
Description
Steps to reproduce
Consider this snippet:
import abc
from collections.abc import Mapping
import logging
class SomeDictMixin(Mapping, abc.ABC):
def logged_get(self, key, default=None):
tmp = self.get(key, default)
logging.debug("Got %s for key %s", tmp, key)
return tmp
The stated purpose of this class would be to create an abstract extension of Mapping
that provides additional functionality as a "mixin". By deriving from Mapping
we declare our requirement that self.get
will be present. By inheriting abc.ABC
we stipulate that this class itself cannot be instantiated until all of its abstracted methods are defined.
Current behavior
Pylint does not appear to understand the semantic consequences of inheriting from abc.ABC
:
example.py:5:0: W0223: Method '__getitem__' is abstract in class 'Mapping' but is not overridden (abstract-method)
example.py:5:0: W0223: Method '__iter__' is abstract in class 'Iterable' but is not overridden (abstract-method)
example.py:5:0: W0223: Method '__len__' is abstract in class 'Sized' but is not overridden (abstract-method)
Namely, that we are explicitly stating that this class is itself abstract.
Expected behavior
Pylint will understand that we are implementing an abstract class and not produce these errors.
pylint --version output
pylint 2.3.1
astroid 2.2.5
Python 3.7.4 (default, Jul 9 2019, 16:32:37)
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]