Method: pylint.checkers.utils.is_registered_in_singledispatch_function
Calls: 3978, Exceptions: 0, Paths: 9Back
Path 1: 3465 calls (0.87)
FunctionDef (3414) AsyncFunctionDef (51)
False (3465)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 2: 286 calls (0.07)
FunctionDef (283) AsyncFunctionDef (3)
False (286)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 3: 120 calls (0.03)
FunctionDef (119) AsyncFunctionDef (1)
False (120)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 4: 66 calls (0.02)
FunctionDef (66)
False (66)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 5: 16 calls (0.0)
FunctionDef (16)
False (8) True (8)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 6: 11 calls (0.0)
FunctionDef (11)
False (11)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 7: 8 calls (0.0)
FunctionDef (8)
True (8)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 8: 4 calls (0.0)
FunctionDef (4)
False (4)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False
Path 9: 2 calls (0.0)
FunctionDef (2)
False (2)
1def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
2 """Check if the given function node is a singledispatch function."""
3
4 singledispatch_qnames = (
5 "functools.singledispatch",
6 "singledispatch.singledispatch",
7 )
8
9 if not isinstance(node, nodes.FunctionDef):
10 return False
11
12 decorators = node.decorators.nodes if node.decorators else []
13 for decorator in decorators:
14 # func.register are function calls or register attributes
15 # when the function is annotated with types
16 if isinstance(decorator, nodes.Call):
17 func = decorator.func
18 elif isinstance(decorator, nodes.Attribute):
19 func = decorator
20 else:
21 continue
22
23 if not isinstance(func, nodes.Attribute) or func.attrname != "register":
24 continue
25
26 try:
27 func_def = next(func.expr.infer())
28 except astroid.InferenceError:
29 continue
30
31 if isinstance(func_def, nodes.FunctionDef):
32 return decorated_with(func_def, singledispatch_qnames)
33
34 return False