Description
Bug description
Related to #3098. Subclasses of an abstract parent class which do not inherit directly from abc.ABC
are considered abstract, and only throw an error during run time when trying to instantiate it.
For example, take this code below. PyCharm correctly determines through a IDE warning that Sub is not abstract, and says Class Sub must implement all abstract methods
, but pylint will ignore this class, as its ancestors inherit from abc.ABC
. Do we not get the best of both worlds (allowing abstract subclasses of abstract parent classes, ie. AbsSub
, while catching non-abstract subclasses of abstract parent classes, ie. Sub
) if we check the bases, instead of the ancestors where that PR to fix the issue above does it?
import abc
import unittest
class Abstract(unittest.TestCase, abc.ABC): # abstract, should have no warning
@abc.abstractmethod
def test_something(self):
pass
@abc.abstractmethod
def test_another_thing(self):
pass
class AbsSub(Abstract, abc.ABC): # abstract, should have no warning
def test_another_thing(self):
return 1
class Sub(AbsSub): # not abstract since it doesn't inherit from abc.ABC directly, should warn
pass
Configuration
No response
Command used
pylint test.py
Pylint output
`NOTHING`
Expected behavior
test.py:19:0: W0223: Method 'test_something' is abstract in class 'Abstract' but is not overridden (abstract-method)
(referring to Sub
)
Pylint version
2.5.0 (but same behavior on 2.15.8)
OS / Environment
Ubuntu 20.04
Additional dependencies
No response