Method: pylint.checkers.classes.class_checker.ClassChecker._check_bases_classes
Calls: 1519, Exceptions: 0, Paths: 3Back
Path 1: 1407 calls (0.93)
ClassDef (1407)
1def _check_bases_classes(self, node: nodes.ClassDef) -> None:
2 """Check that the given class node implements abstract methods from
3 base classes.
4 """
5
6 def is_abstract(method: nodes.FunctionDef) -> bool:
7 return method.is_abstract(pass_is_abstract=False) # type: ignore[no-any-return]
8
9 # check if this class abstract
10 if class_is_abstract(node):
11 return
12
13 methods = sorted(
14 unimplemented_abstract_methods(node, is_abstract).items(),
15 key=lambda item: item[0],
16 )
17 for name, method in methods:
18 owner = method.parent.frame(future=True)
19 if owner is node:
20 continue
21 # owner is not this class, it must be a parent class
22 # check that the ancestor's method is not abstract
23 if name in node.locals:
24 # it is redefined as an attribute or with a descriptor
25 continue
26
27 self.add_message(
28 "abstract-method",
29 node=node,
30 args=(name, owner.name, node.name),
31 confidence=INFERENCE,
32 )
Path 2: 79 calls (0.05)
ClassDef (79)
None (79)
1def _check_bases_classes(self, node: nodes.ClassDef) -> None:
2 """Check that the given class node implements abstract methods from
3 base classes.
4 """
5
6 def is_abstract(method: nodes.FunctionDef) -> bool:
7 return method.is_abstract(pass_is_abstract=False) # type: ignore[no-any-return]
8
9 # check if this class abstract
10 if class_is_abstract(node):
11 return
12
13 methods = sorted(
14 unimplemented_abstract_methods(node, is_abstract).items(),
15 key=lambda item: item[0],
16 )
17 for name, method in methods:
18 owner = method.parent.frame(future=True)
19 if owner is node:
20 continue
21 # owner is not this class, it must be a parent class
22 # check that the ancestor's method is not abstract
23 if name in node.locals:
24 # it is redefined as an attribute or with a descriptor
25 continue
26
27 self.add_message(
28 "abstract-method",
29 node=node,
30 args=(name, owner.name, node.name),
31 confidence=INFERENCE,
32 )
Path 3: 33 calls (0.02)
ClassDef (33)
1def _check_bases_classes(self, node: nodes.ClassDef) -> None:
2 """Check that the given class node implements abstract methods from
3 base classes.
4 """
5
6 def is_abstract(method: nodes.FunctionDef) -> bool:
7 return method.is_abstract(pass_is_abstract=False) # type: ignore[no-any-return]
8
9 # check if this class abstract
10 if class_is_abstract(node):
11 return
12
13 methods = sorted(
14 unimplemented_abstract_methods(node, is_abstract).items(),
15 key=lambda item: item[0],
16 )
17 for name, method in methods:
18 owner = method.parent.frame(future=True)
19 if owner is node:
20 continue
21 # owner is not this class, it must be a parent class
22 # check that the ancestor's method is not abstract
23 if name in node.locals:
24 # it is redefined as an attribute or with a descriptor
25 continue
26
27 self.add_message(
28 "abstract-method",
29 node=node,
30 args=(name, owner.name, node.name),
31 confidence=INFERENCE,
32 )