Skip to content

Commit 41fd241

Browse files
committed
work and test class
1 parent 1baa10e commit 41fd241

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pylint/checkers/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,9 @@ def class_is_abstract(node: nodes.ClassDef) -> bool:
11721172
if meta.name == "ABCMeta" and meta.root().name in ABC_MODULES:
11731173
return True
11741174

1175-
for ancestor in node.ancestors():
1176-
if ancestor.name == "ABC" and ancestor.root().name in ABC_MODULES:
1175+
# As well as directly inherited ABC class
1176+
for base in node.bases:
1177+
if base.as_string() in ("abc.ABC", "ABC"):
11771178
# abc.ABC inheritance
11781179
return True
11791180

tests/functional/a/abstract/abstract_method.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta):
4444
"""
4545

4646

47-
class Concrete(Abstract): # [abstract-method]
47+
class ConcreteA(AbstractC):
48+
"""
49+
Concrete class.
50+
51+
Should trigger a warning since this class does
52+
not directly inherit from abc.ABC.
53+
"""
54+
55+
56+
class ConcreteB(Abstract): # [abstract-method]
4857
"""Concrete class"""
4958

5059
def aaaa(self):

0 commit comments

Comments
 (0)