Method: pylint.checkers.format.FormatChecker._check_multi_statement_line
Calls: 71, Exceptions: 0, Paths: 10Back
Path 1: 24 calls (0.34)
Import (16) Expr (4) AugAssign (1) Return (1) Assign (1) Raise (1)
16 (2) 137 (1) 60 (1) 18 (1) 20 (1) 26 (1) 176 (1) 177 (1) 1 (1) 2 (1)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 2: 22 calls (0.31)
TryExcept (22)
19 (4) 133 (1) 166 (1) 175 (1) 186 (1) 28 (1) 99 (1) 31 (1) 44 (1) 10 (1)
None (22)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 3: 12 calls (0.17)
Expr (12)
28 (2) 30 (2) 139 (1) 142 (1) 34 (1) 40 (1) 71 (1) 75 (1) 88 (1) 91 (1)
None (12)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 4: 3 calls (0.04)
Return (3)
12 (1) 14 (1) 86 (1)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 5: 2 calls (0.03)
Pass (2)
9 (2)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 6: 2 calls (0.03)
Pass (1) Assign (1)
13 (1) 15 (1)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 7: 2 calls (0.03)
Assign (2)
17 (2)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 8: 2 calls (0.03)
Pass (1) Assign (1)
13 (1) 15 (1)
None (2)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 9: 1 calls (0.01)
Pass (1)
7 (1)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2
Path 10: 1 calls (0.01)
Pass (1)
7 (1)
None (1)
1def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
2 """Check for lines containing multiple statements."""
3 # Do not warn about multiple nested context managers
4 # in with statements.
5 if isinstance(node, nodes.With):
6 return
7 # For try... except... finally..., the two nodes
8 # appear to be on the same line due to how the AST is built.
9 if isinstance(node, nodes.TryExcept) and isinstance(
10 node.parent, nodes.TryFinally
11 ):
12 return
13 if (
14 isinstance(node.parent, nodes.If)
15 and not node.parent.orelse
16 and self.linter.config.single_line_if_stmt
17 ):
18 return
19 if (
20 isinstance(node.parent, nodes.ClassDef)
21 and len(node.parent.body) == 1
22 and self.linter.config.single_line_class_stmt
23 ):
24 return
25
26 # Functions stubs with ``Ellipsis`` as body are exempted.
27 if (
28 isinstance(node.parent, nodes.FunctionDef)
29 and isinstance(node, nodes.Expr)
30 and isinstance(node.value, nodes.Const)
31 and node.value.value is Ellipsis
32 ):
33 return
34
35 self.add_message("multiple-statements", node=node)
36 self._visited_lines[line] = 2