Method: pylint.checkers.classes.class_checker._called_in_methods
Calls: 39, Exceptions: 33, Paths: 4Back
Path 1: 30 calls (0.77)
FunctionDef (30)
ClassDef (30)
('__init__', '__new__', 'setUp', '__post_init__') (30)
False (30)
AttributeInferenceError (30)
1def _called_in_methods(
2 func: LocalsDictNodeNG,
3 klass: nodes.ClassDef,
4 methods: Sequence[str],
5) -> bool:
6 """Check if the func was called in any of the given methods,
7 belonging to the *klass*.
8
9 Returns True if so, False otherwise.
10 """
11 if not isinstance(func, nodes.FunctionDef):
12 return False
13 for method in methods:
14 try:
15 inferred = klass.getattr(method)
16 except astroid.NotFoundError:
17 continue
18 for infer_method in inferred:
19 for call in infer_method.nodes_of_class(nodes.Call):
20 try:
21 bound = next(call.func.infer())
22 except (astroid.InferenceError, StopIteration):
23 continue
24 if not isinstance(bound, astroid.BoundMethod):
25 continue
26 func_obj = bound._proxied
27 if isinstance(func_obj, astroid.UnboundMethod):
28 func_obj = func_obj._proxied
29 if func_obj.name == func.name:
30 return True
31 return False
Path 2: 4 calls (0.1)
FunctionDef (4)
ClassDef (4)
('__init__', '__new__', 'setUp', '__post_init__') (4)
True (4)
1def _called_in_methods(
2 func: LocalsDictNodeNG,
3 klass: nodes.ClassDef,
4 methods: Sequence[str],
5) -> bool:
6 """Check if the func was called in any of the given methods,
7 belonging to the *klass*.
8
9 Returns True if so, False otherwise.
10 """
11 if not isinstance(func, nodes.FunctionDef):
12 return False
13 for method in methods:
14 try:
15 inferred = klass.getattr(method)
16 except astroid.NotFoundError:
17 continue
18 for infer_method in inferred:
19 for call in infer_method.nodes_of_class(nodes.Call):
20 try:
21 bound = next(call.func.infer())
22 except (astroid.InferenceError, StopIteration):
23 continue
24 if not isinstance(bound, astroid.BoundMethod):
25 continue
26 func_obj = bound._proxied
27 if isinstance(func_obj, astroid.UnboundMethod):
28 func_obj = func_obj._proxied
29 if func_obj.name == func.name:
30 return True
31 return False
Path 3: 3 calls (0.08)
FunctionDef (3)
ClassDef (3)
('__init__', '__new__', 'setUp', '__post_init__') (3)
False (3)
AttributeInferenceError (3)
1def _called_in_methods(
2 func: LocalsDictNodeNG,
3 klass: nodes.ClassDef,
4 methods: Sequence[str],
5) -> bool:
6 """Check if the func was called in any of the given methods,
7 belonging to the *klass*.
8
9 Returns True if so, False otherwise.
10 """
11 if not isinstance(func, nodes.FunctionDef):
12 return False
13 for method in methods:
14 try:
15 inferred = klass.getattr(method)
16 except astroid.NotFoundError:
17 continue
18 for infer_method in inferred:
19 for call in infer_method.nodes_of_class(nodes.Call):
20 try:
21 bound = next(call.func.infer())
22 except (astroid.InferenceError, StopIteration):
23 continue
24 if not isinstance(bound, astroid.BoundMethod):
25 continue
26 func_obj = bound._proxied
27 if isinstance(func_obj, astroid.UnboundMethod):
28 func_obj = func_obj._proxied
29 if func_obj.name == func.name:
30 return True
31 return False
Path 4: 2 calls (0.05)
Module (2)
ClassDef (2)
('__init__', '__new__', 'setUp', '__post_init__') (2)
False (2)
1def _called_in_methods(
2 func: LocalsDictNodeNG,
3 klass: nodes.ClassDef,
4 methods: Sequence[str],
5) -> bool:
6 """Check if the func was called in any of the given methods,
7 belonging to the *klass*.
8
9 Returns True if so, False otherwise.
10 """
11 if not isinstance(func, nodes.FunctionDef):
12 return False
13 for method in methods:
14 try:
15 inferred = klass.getattr(method)
16 except astroid.NotFoundError:
17 continue
18 for infer_method in inferred:
19 for call in infer_method.nodes_of_class(nodes.Call):
20 try:
21 bound = next(call.func.infer())
22 except (astroid.InferenceError, StopIteration):
23 continue
24 if not isinstance(bound, astroid.BoundMethod):
25 continue
26 func_obj = bound._proxied
27 if isinstance(func_obj, astroid.UnboundMethod):
28 func_obj = func_obj._proxied
29 if func_obj.name == func.name:
30 return True
31 return False