Method: pylint.checkers.base.basic_checker.BasicChecker.visit_lambda
Calls: 208, Exceptions: 0, Paths: 19Back
Path 1: 149 calls (0.72)
Lambda (149)
None (149)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 2: 14 calls (0.07)
Lambda (14)
None (14)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 3: 14 calls (0.07)
Lambda (14)
None (14)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 4: 4 calls (0.02)
Lambda (4)
None (4)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 5: 4 calls (0.02)
Lambda (4)
None (4)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 6: 3 calls (0.01)
Lambda (3)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 7: 3 calls (0.01)
Lambda (3)
None (3)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 8: 3 calls (0.01)
Lambda (3)
None (3)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 9: 2 calls (0.01)
Lambda (2)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 10: 2 calls (0.01)
Lambda (2)
None (2)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 11: 2 calls (0.01)
Lambda (2)
None (2)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 12: 1 calls (0.0)
Lambda (1)
None (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 13: 1 calls (0.0)
Lambda (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 14: 1 calls (0.0)
Lambda (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 15: 1 calls (0.0)
Lambda (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 16: 1 calls (0.0)
Lambda (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 17: 1 calls (0.0)
Lambda (1)
None (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 18: 1 calls (0.0)
Lambda (1)
None (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)
Path 19: 1 calls (0.0)
Lambda (1)
None (1)
1@utils.only_required_for_messages("unnecessary-lambda")
2 def visit_lambda(self, node: nodes.Lambda) -> None:
3 """Check whether the lambda is suspicious."""
4 # if the body of the lambda is a call expression with the same
5 # argument list as the lambda itself, then the lambda is
6 # possibly unnecessary and at least suspicious.
7 if node.args.defaults:
8 # If the arguments of the lambda include defaults, then a
9 # judgment cannot be made because there is no way to check
10 # that the defaults defined by the lambda are the same as
11 # the defaults defined by the function called in the body
12 # of the lambda.
13 return
14 call = node.body
15 if not isinstance(call, nodes.Call):
16 # The body of the lambda must be a function call expression
17 # for the lambda to be unnecessary.
18 return
19 if isinstance(node.body.func, nodes.Attribute) and isinstance(
20 node.body.func.expr, nodes.Call
21 ):
22 # Chained call, the intermediate call might
23 # return something else (but we don't check that, yet).
24 return
25
26 call_site = astroid.arguments.CallSite.from_call(call)
27 ordinary_args = list(node.args.args)
28 new_call_args = list(self._filter_vararg(node, call.args))
29 if node.args.kwarg:
30 if self._has_variadic_argument(call.kwargs, node.args.kwarg):
31 return
32
33 if node.args.vararg:
34 if self._has_variadic_argument(call.starargs, node.args.vararg):
35 return
36 elif call.starargs:
37 return
38
39 if call.keywords:
40 # Look for additional keyword arguments that are not part
41 # of the lambda's signature
42 lambda_kwargs = {keyword.name for keyword in node.args.defaults}
43 if len(lambda_kwargs) != len(call_site.keyword_arguments):
44 # Different lengths, so probably not identical
45 return
46 if set(call_site.keyword_arguments).difference(lambda_kwargs):
47 return
48
49 # The "ordinary" arguments must be in a correspondence such that:
50 # ordinary_args[i].name == call.args[i].name.
51 if len(ordinary_args) != len(new_call_args):
52 return
53 for arg, passed_arg in zip(ordinary_args, new_call_args):
54 if not isinstance(passed_arg, nodes.Name):
55 return
56 if arg.name != passed_arg.name:
57 return
58
59 self.add_message("unnecessary-lambda", line=node.fromlineno, node=node)