Method: pylint.checkers.design_analysis._get_parents_iter
Calls: 1520, Exceptions: 0, Paths: 4Back
Path 1: 1045 calls (0.69)
ClassDef (1045)
frozenset({'collections.namedtuple', '_collections_abc.Collection', '_collections_abc.Iterable', '_collections_abc.ByteString', 'typing.Tuple', 'typin...
1def _get_parents_iter(
2 node: nodes.ClassDef, ignored_parents: frozenset[str]
3) -> Iterator[nodes.ClassDef]:
4 r"""Get parents of ``node``, excluding ancestors of ``ignored_parents``.
5
6 If we have the following inheritance diagram:
7
8 F
9 /
10 D E
11 \/
12 B C
13 \/
14 A # class A(B, C): ...
15
16 And ``ignored_parents`` is ``{"E"}``, then this function will return
17 ``{A, B, C, D}`` -- both ``E`` and its ancestors are excluded.
18 """
19 parents: set[nodes.ClassDef] = set()
20 to_explore = list(node.ancestors(recurs=False))
21 while to_explore:
22 parent = to_explore.pop()
23 if parent.qname() in ignored_parents:
24 continue
25 if parent not in parents:
26 # This guard might appear to be performing the same function as
27 # adding the resolved parents to a set to eliminate duplicates
28 # (legitimate due to diamond inheritance patterns), but its
29 # additional purpose is to prevent cycles (not normally possible,
30 # but potential due to inference) and thus guarantee termination
31 # of the while-loop
32 yield parent
33 parents.add(parent)
34 to_explore.extend(parent.ancestors(recurs=False))
Path 2: 446 calls (0.29)
ClassDef (446)
frozenset({'collections.namedtuple', '_collections_abc.Collection', '_collections_abc.Iterable', '_collections_abc.ByteString', 'typing.Tuple', 'typin...
ClassDef (755)
1def _get_parents_iter(
2 node: nodes.ClassDef, ignored_parents: frozenset[str]
3) -> Iterator[nodes.ClassDef]:
4 r"""Get parents of ``node``, excluding ancestors of ``ignored_parents``.
5
6 If we have the following inheritance diagram:
7
8 F
9 /
10 D E
11 \/
12 B C
13 \/
14 A # class A(B, C): ...
15
16 And ``ignored_parents`` is ``{"E"}``, then this function will return
17 ``{A, B, C, D}`` -- both ``E`` and its ancestors are excluded.
18 """
19 parents: set[nodes.ClassDef] = set()
20 to_explore = list(node.ancestors(recurs=False))
21 while to_explore:
22 parent = to_explore.pop()
23 if parent.qname() in ignored_parents:
24 continue
25 if parent not in parents:
26 # This guard might appear to be performing the same function as
27 # adding the resolved parents to a set to eliminate duplicates
28 # (legitimate due to diamond inheritance patterns), but its
29 # additional purpose is to prevent cycles (not normally possible,
30 # but potential due to inference) and thus guarantee termination
31 # of the while-loop
32 yield parent
33 parents.add(parent)
34 to_explore.extend(parent.ancestors(recurs=False))
Path 3: 24 calls (0.02)
ClassDef (24)
frozenset({'collections.namedtuple', '_collections_abc.Collection', '_collections_abc.Iterable', '_collections_abc.ByteString', 'typing.Tuple', 'typin...
1def _get_parents_iter(
2 node: nodes.ClassDef, ignored_parents: frozenset[str]
3) -> Iterator[nodes.ClassDef]:
4 r"""Get parents of ``node``, excluding ancestors of ``ignored_parents``.
5
6 If we have the following inheritance diagram:
7
8 F
9 /
10 D E
11 \/
12 B C
13 \/
14 A # class A(B, C): ...
15
16 And ``ignored_parents`` is ``{"E"}``, then this function will return
17 ``{A, B, C, D}`` -- both ``E`` and its ancestors are excluded.
18 """
19 parents: set[nodes.ClassDef] = set()
20 to_explore = list(node.ancestors(recurs=False))
21 while to_explore:
22 parent = to_explore.pop()
23 if parent.qname() in ignored_parents:
24 continue
25 if parent not in parents:
26 # This guard might appear to be performing the same function as
27 # adding the resolved parents to a set to eliminate duplicates
28 # (legitimate due to diamond inheritance patterns), but its
29 # additional purpose is to prevent cycles (not normally possible,
30 # but potential due to inference) and thus guarantee termination
31 # of the while-loop
32 yield parent
33 parents.add(parent)
34 to_explore.extend(parent.ancestors(recurs=False))
Path 4: 5 calls (0.0)
ClassDef (5)
frozenset({'collections.namedtuple', '_collections_abc.Collection', '_collections_abc.Iterable', '_collections_abc.ByteString', 'typing.Tuple', 'typin...
ClassDef (6)
1def _get_parents_iter(
2 node: nodes.ClassDef, ignored_parents: frozenset[str]
3) -> Iterator[nodes.ClassDef]:
4 r"""Get parents of ``node``, excluding ancestors of ``ignored_parents``.
5
6 If we have the following inheritance diagram:
7
8 F
9 /
10 D E
11 \/
12 B C
13 \/
14 A # class A(B, C): ...
15
16 And ``ignored_parents`` is ``{"E"}``, then this function will return
17 ``{A, B, C, D}`` -- both ``E`` and its ancestors are excluded.
18 """
19 parents: set[nodes.ClassDef] = set()
20 to_explore = list(node.ancestors(recurs=False))
21 while to_explore:
22 parent = to_explore.pop()
23 if parent.qname() in ignored_parents:
24 continue
25 if parent not in parents:
26 # This guard might appear to be performing the same function as
27 # adding the resolved parents to a set to eliminate duplicates
28 # (legitimate due to diamond inheritance patterns), but its
29 # additional purpose is to prevent cycles (not normally possible,
30 # but potential due to inference) and thus guarantee termination
31 # of the while-loop
32 yield parent
33 parents.add(parent)
34 to_explore.extend(parent.ancestors(recurs=False))