Method: pylint.checkers.utils.is_subclass_of
Calls: 18, Exceptions: 3, Paths: 3Back
Path 1: 8 calls (0.44)
ClassDef (8)
ClassDef (8)
False (8)
1def is_subclass_of(child: nodes.ClassDef, parent: nodes.ClassDef) -> bool:
2 """Check if first node is a subclass of second node.
3
4 :param child: Node to check for subclass.
5 :param parent: Node to check for superclass.
6 :returns: True if child is derived from parent. False otherwise.
7 """
8 if not all(isinstance(node, nodes.ClassDef) for node in (child, parent)):
9 return False
10
11 for ancestor in child.ancestors():
12 try:
13 if astroid.helpers.is_subtype(ancestor, parent):
14 return True
15 except astroid.exceptions._NonDeducibleTypeHierarchy:
16 continue
17 return False
Path 2: 7 calls (0.39)
ClassDef (7)
ClassDef (7)
True (7)
1def is_subclass_of(child: nodes.ClassDef, parent: nodes.ClassDef) -> bool:
2 """Check if first node is a subclass of second node.
3
4 :param child: Node to check for subclass.
5 :param parent: Node to check for superclass.
6 :returns: True if child is derived from parent. False otherwise.
7 """
8 if not all(isinstance(node, nodes.ClassDef) for node in (child, parent)):
9 return False
10
11 for ancestor in child.ancestors():
12 try:
13 if astroid.helpers.is_subtype(ancestor, parent):
14 return True
15 except astroid.exceptions._NonDeducibleTypeHierarchy:
16 continue
17 return False
Path 3: 3 calls (0.17)
None (2) ClassDef (1)
None (2) ClassDef (1)
False (3)
GeneratorExit (3)
1def is_subclass_of(child: nodes.ClassDef, parent: nodes.ClassDef) -> bool:
2 """Check if first node is a subclass of second node.
3
4 :param child: Node to check for subclass.
5 :param parent: Node to check for superclass.
6 :returns: True if child is derived from parent. False otherwise.
7 """
8 if not all(isinstance(node, nodes.ClassDef) for node in (child, parent)):
9 return False
10
11 for ancestor in child.ancestors():
12 try:
13 if astroid.helpers.is_subtype(ancestor, parent):
14 return True
15 except astroid.exceptions._NonDeducibleTypeHierarchy:
16 continue
17 return False