Method: pylint.checkers.utils.get_node_last_lineno
Calls: 6939, Exceptions: 0, Paths: 5Back
Path 1: 3802 calls (0.55)
FunctionDef (2099) ClassDef (1015) Module (297) For (90) If (82) ExceptHandler (64) While (59) AsyncFunctionDef (54) With (36) AsyncWith (4)
9 (99) 11 (95) 13 (85) 6 (83) 12 (73) 16 (69) 15 (68) 25 (58) 27 (57) 22 (56)
1def get_node_last_lineno(node: nodes.NodeNG) -> int:
2 """Get the last lineno of the given node.
3
4 For a simple statement this will just be node.lineno,
5 but for a node that has child statements (e.g. a method) this will be the lineno of the last
6 child statement recursively.
7 """
8 # 'finalbody' is always the last clause in a try statement, if present
9 if getattr(node, "finalbody", False):
10 return get_node_last_lineno(node.finalbody[-1])
11 # For if, while, and for statements 'orelse' is always the last clause.
12 # For try statements 'orelse' is the last in the absence of a 'finalbody'
13 if getattr(node, "orelse", False):
14 return get_node_last_lineno(node.orelse[-1])
15 # try statements have the 'handlers' last if there is no 'orelse' or 'finalbody'
16 if getattr(node, "handlers", False):
17 return get_node_last_lineno(node.handlers[-1])
18 # All compound statements have a 'body'
19 if getattr(node, "body", False):
20 return get_node_last_lineno(node.body[-1])
21 # Not a compound statement
22 return node.lineno # type: ignore[no-any-return]
Path 2: 2930 calls (0.42)
Return (876) Expr (632) Pass (582) Assign (312) Raise (134) Module (125) AnnAssign (79) FunctionDef (53) AugAssign (45) Import (25)
0 (125) 9 (80) 11 (74) 13 (62) 6 (61) 12 (55) 15 (52) 16 (50) 7 (47) 20 (43)
1def get_node_last_lineno(node: nodes.NodeNG) -> int:
2 """Get the last lineno of the given node.
3
4 For a simple statement this will just be node.lineno,
5 but for a node that has child statements (e.g. a method) this will be the lineno of the last
6 child statement recursively.
7 """
8 # 'finalbody' is always the last clause in a try statement, if present
9 if getattr(node, "finalbody", False):
10 return get_node_last_lineno(node.finalbody[-1])
11 # For if, while, and for statements 'orelse' is always the last clause.
12 # For try statements 'orelse' is the last in the absence of a 'finalbody'
13 if getattr(node, "orelse", False):
14 return get_node_last_lineno(node.orelse[-1])
15 # try statements have the 'handlers' last if there is no 'orelse' or 'finalbody'
16 if getattr(node, "handlers", False):
17 return get_node_last_lineno(node.handlers[-1])
18 # All compound statements have a 'body'
19 if getattr(node, "body", False):
20 return get_node_last_lineno(node.body[-1])
21 # Not a compound statement
22 return node.lineno # type: ignore[no-any-return]
Path 3: 128 calls (0.02)
If (120) TryExcept (6) While (1) For (1)
56 (15) 31 (12) 89 (12) 11 (6) 21 (4) 23 (4) 36 (3) 85 (3) 155 (2) 101 (2)
1def get_node_last_lineno(node: nodes.NodeNG) -> int:
2 """Get the last lineno of the given node.
3
4 For a simple statement this will just be node.lineno,
5 but for a node that has child statements (e.g. a method) this will be the lineno of the last
6 child statement recursively.
7 """
8 # 'finalbody' is always the last clause in a try statement, if present
9 if getattr(node, "finalbody", False):
10 return get_node_last_lineno(node.finalbody[-1])
11 # For if, while, and for statements 'orelse' is always the last clause.
12 # For try statements 'orelse' is the last in the absence of a 'finalbody'
13 if getattr(node, "orelse", False):
14 return get_node_last_lineno(node.orelse[-1])
15 # try statements have the 'handlers' last if there is no 'orelse' or 'finalbody'
16 if getattr(node, "handlers", False):
17 return get_node_last_lineno(node.handlers[-1])
18 # All compound statements have a 'body'
19 if getattr(node, "body", False):
20 return get_node_last_lineno(node.body[-1])
21 # Not a compound statement
22 return node.lineno # type: ignore[no-any-return]
Path 4: 64 calls (0.01)
TryExcept (64)
51 (3) 30 (2) 46 (2) 80 (2) 85 (2) 11 (2) 18 (2) 116 (2) 110 (2) 12 (2)
1def get_node_last_lineno(node: nodes.NodeNG) -> int:
2 """Get the last lineno of the given node.
3
4 For a simple statement this will just be node.lineno,
5 but for a node that has child statements (e.g. a method) this will be the lineno of the last
6 child statement recursively.
7 """
8 # 'finalbody' is always the last clause in a try statement, if present
9 if getattr(node, "finalbody", False):
10 return get_node_last_lineno(node.finalbody[-1])
11 # For if, while, and for statements 'orelse' is always the last clause.
12 # For try statements 'orelse' is the last in the absence of a 'finalbody'
13 if getattr(node, "orelse", False):
14 return get_node_last_lineno(node.orelse[-1])
15 # try statements have the 'handlers' last if there is no 'orelse' or 'finalbody'
16 if getattr(node, "handlers", False):
17 return get_node_last_lineno(node.handlers[-1])
18 # All compound statements have a 'body'
19 if getattr(node, "body", False):
20 return get_node_last_lineno(node.body[-1])
21 # Not a compound statement
22 return node.lineno # type: ignore[no-any-return]
Path 5: 15 calls (0.0)
TryFinally (15)
85 (2) 9 (2) 5 (2) 171 (1) 182 (1) 194 (1) 16 (1) 29 (1) 23 (1) 8 (1)
1def get_node_last_lineno(node: nodes.NodeNG) -> int:
2 """Get the last lineno of the given node.
3
4 For a simple statement this will just be node.lineno,
5 but for a node that has child statements (e.g. a method) this will be the lineno of the last
6 child statement recursively.
7 """
8 # 'finalbody' is always the last clause in a try statement, if present
9 if getattr(node, "finalbody", False):
10 return get_node_last_lineno(node.finalbody[-1])
11 # For if, while, and for statements 'orelse' is always the last clause.
12 # For try statements 'orelse' is the last in the absence of a 'finalbody'
13 if getattr(node, "orelse", False):
14 return get_node_last_lineno(node.orelse[-1])
15 # try statements have the 'handlers' last if there is no 'orelse' or 'finalbody'
16 if getattr(node, "handlers", False):
17 return get_node_last_lineno(node.handlers[-1])
18 # All compound statements have a 'body'
19 if getattr(node, "body", False):
20 return get_node_last_lineno(node.body[-1])
21 # Not a compound statement
22 return node.lineno # type: ignore[no-any-return]