Method: pylint.checkers.format.FormatChecker.visit_default
Calls: 81458, Exceptions: 12358, Paths: 18Back
Path 1: 61182 calls (0.75)
Name (16317) Const (11990) AssignName (9212) Call (5658) Arguments (3729) Attribute (3200) List (1585) Subscript (1198) Compare (1139) Module (1107)
None (61182)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 2: 5920 calls (0.07)
Assign (2138) Expr (1951) Return (461) ImportFrom (368) AnnAssign (288) Import (264) AugAssign (143) Assert (119) Raise (114) Delete (23)
AttributeError (5920)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 3: 5789 calls (0.07)
Assign (1383) Pass (1290) Expr (1171) Return (1150) Raise (198) AnnAssign (133) AugAssign (124) Break (111) Import (80) ImportFrom (60)
AttributeError (5789)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 4: 5053 calls (0.06)
FunctionDef (2363) ClassDef (1340) If (569) For (345) TryExcept (128) With (108) While (79) ExceptHandler (48) AsyncFunctionDef (43) TryFinally (20)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 5: 2250 calls (0.03)
FunctionDef (885) If (600) ExceptHandler (290) For (175) TryExcept (131) With (56) ClassDef (55) TryFinally (24) While (21) AsyncFunctionDef (8)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 6: 586 calls (0.01)
Import (217) ImportFrom (201) Assign (137) Expr (25) Assert (2) Global (1) Return (1) Raise (1) Match (1)
AttributeError (586)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 7: 335 calls (0.0)
FunctionDef (175) ClassDef (123) TryExcept (16) If (9) While (4) TryFinally (3) AsyncFunctionDef (2) For (2) With (1)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 8: 139 calls (0.0)
Expr (29) Pass (27) Raise (25) Assign (16) If (13) ExceptHandler (12) TryExcept (11) Return (2) With (2) FunctionDef (1)
None (139)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 9: 53 calls (0.0)
TryExcept (22) Expr (15) Pass (6) Return (4) Assign (4) AugAssign (1) Raise (1)
None (53)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 10: 44 calls (0.0)
Pass (19) Expr (15) Assign (6) Raise (2) Continue (1) Break (1)
AttributeError (44)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 11: 32 calls (0.0)
FunctionDef (32)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 12: 18 calls (0.0)
Raise (7) Expr (6) Assign (2) If (1) Return (1) TryExcept (1)
None (18)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 13: 18 calls (0.0)
Import (16) Expr (1) Assign (1)
None (18)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 14: 12 calls (0.0)
FunctionDef (11) AsyncFunctionDef (1)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 15: 8 calls (0.0)
TryFinally (5) If (2) For (1)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 16: 7 calls (0.0)
Expr (4) Assign (3)
KeyError (7)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 17: 7 calls (0.0)
ExceptHandler (7)
KeyError (7)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")
Path 18: 5 calls (0.0)
Assign (5)
KeyError (5)
1@only_required_for_messages("multiple-statements")
2 def visit_default(self, node: nodes.NodeNG) -> None:
3 """Check the node line number and check it if not yet done."""
4 if not node.is_statement:
5 return
6 if not node.root().pure_python:
7 return
8 prev_sibl = node.previous_sibling()
9 if prev_sibl is not None:
10 prev_line = prev_sibl.fromlineno
11 # The line on which a 'finally': occurs in a 'try/finally'
12 # is not directly represented in the AST. We infer it
13 # by taking the last line of the body and adding 1, which
14 # should be the line of finally:
15 elif (
16 isinstance(node.parent, nodes.TryFinally) and node in node.parent.finalbody
17 ):
18 prev_line = node.parent.body[0].tolineno + 1
19 elif isinstance(node.parent, nodes.Module):
20 prev_line = 0
21 else:
22 prev_line = node.parent.statement(future=True).fromlineno
23 line = node.fromlineno
24 assert line, node
25 if prev_line == line and self._visited_lines.get(line) != 2:
26 self._check_multi_statement_line(node, line)
27 return
28 if line in self._visited_lines:
29 return
30 try:
31 tolineno = node.blockstart_tolineno
32 except AttributeError:
33 tolineno = node.tolineno
34 assert tolineno, node
35 lines: list[str] = []
36 for line in range(line, tolineno + 1): # noqa: B020
37 self._visited_lines[line] = 1
38 try:
39 lines.append(self._lines[line].rstrip())
40 except KeyError:
41 lines.append("")