Method: pylint.checkers.lambda_expressions.LambdaExpressionChecker.visit_assign
Calls: 3684, Exceptions: 0, Paths: 10Back
Path 1: 2924 calls (0.79)
Assign (2924)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 2: 520 calls (0.14)
Assign (520)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 3: 96 calls (0.03)
Assign (96)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 4: 79 calls (0.02)
Assign (79)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 5: 42 calls (0.01)
Assign (42)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 6: 8 calls (0.0)
Assign (8)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 7: 6 calls (0.0)
Assign (6)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 8: 4 calls (0.0)
Assign (4)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 9: 3 calls (0.0)
Assign (3)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )
Path 10: 2 calls (0.0)
Assign (2)
1def visit_assign(self, node: nodes.Assign) -> None:
2 """Check if lambda expression is assigned to a variable."""
3 if isinstance(node.targets[0], nodes.AssignName) and isinstance(
4 node.value, nodes.Lambda
5 ):
6 self.add_message(
7 "unnecessary-lambda-assignment",
8 node=node.value,
9 confidence=HIGH,
10 )
11 elif isinstance(node.targets[0], nodes.Tuple) and isinstance(
12 node.value, (nodes.Tuple, nodes.List)
13 ):
14 # Iterate over tuple unpacking assignment elements and
15 # see if any lambdas are assigned to a variable.
16 # N.B. We may encounter W0632 (unbalanced-tuple-unpacking)
17 # and still need to flag the lambdas that are being assigned.
18 for lhs_elem, rhs_elem in zip_longest(
19 node.targets[0].elts, node.value.elts
20 ):
21 if lhs_elem is None or rhs_elem is None:
22 # unbalanced tuple unpacking. stop checking.
23 break
24 if isinstance(lhs_elem, nodes.AssignName) and isinstance(
25 rhs_elem, nodes.Lambda
26 ):
27 self.add_message(
28 "unnecessary-lambda-assignment",
29 node=rhs_elem,
30 confidence=HIGH,
31 )