Method: pylint.utils.file_state.FileState._set_message_state_in_block
Calls: 514242, Exceptions: 0, Paths: 16Back
Path 1: 490098 calls (0.95)
MessageDefinition (490098)
{1: False} (166092) {2: False} (119000) {3: False} (80315) {4: False} (36364) {5: False} (17239) {6: False} (12014) {7: False} (7808) {9: False} (3020...
Name (103994) Const (59313) AssignName (57889) Call (35501) Arguments (24937) FunctionDef (23215) Assign (21136) Expr (20095) Attribute (20085) Return...
11 (6436) 13 (6239) 16 (6143) 14 (6035) 23 (5809) 18 (5792) 10 (5737) 17 (5732) 28 (5730) 12 (5705)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 2: 20600 calls (0.04)
MessageDefinition (20600)
{} (20600)
Name (4615) AssignName (2387) Const (2201) Call (1337) FunctionDef (1135) Arguments (1125) Assign (1092) Attribute (858) Expr (763) Return (730)
94 (176) 124 (164) 98 (162) 42 (160) 157 (158) 83 (157) 126 (156) 77 (153) 108 (151) 64 (144)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 3: 2959 calls (0.01)
MessageDefinition (2959)
{1: False} (1323) {2: False} (721) {3: False} (445) {4: False} (205) {5: False} (84) {6: False} (66) {7: False} (52) {9: False} (20) {10: False} (19) ...
Module (2959)
4 (649) 3 (623) 5 (502) 2 (348) 6 (251) 7 (235) 8 (92) 9 (73) 11 (45) 100 (40)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 4: 244 calls (0.0)
MessageDefinition (244)
{1: False} (105) {2: False} (45) {3: False} (26) {4: False} (16) {1: True} (12) {5: False} (9) {6: False} (7) {7: False} (4) {32: False} (3) {9: False...
Module (244)
4 (64) 5 (32) 2 (26) 100 (24) 3 (22) 8 (19) 6 (15) 7 (15) 9 (10) 13 (7)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 5: 103 calls (0.0)
MessageDefinition (103)
{6: False} (7) {5: False} (4) {9: False} (4) {31: False} (4) {24: False} (4) {87: False} (2) {89: False} (2) {40: False} (2) {8: False} (2) {107: Fals...
AssignName (36) Name (25) ImportFrom (14) Import (13) Const (10) Arguments (4) Global (1)
6 (7) 5 (4) 9 (4) 31 (4) 24 (4) 87 (2) 89 (2) 40 (2) 8 (2) 107 (2)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 6: 67 calls (0.0)
MessageDefinition (67)
{5: False} (13) {17: False} (6) {151: False} (4) {6: False} (4) {85: False} (4) {72: False} (3) {27: False} (3) {152: False} (3) {164: False} (2) {10:...
Module (67)
5 (22) 4 (12) 3 (11) 2 (9) 6 (7) 7 (5) 8 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 7: 44 calls (0.0)
MessageDefinition (44)
{1: True} (38) {2: True} (3) {1: False} (2) {3: False} (1)
Module (44)
100 (38) 4 (3) 6 (2) 5 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 8: 37 calls (0.0)
MessageDefinition (37)
{6: False} (6) {13: False} (2) {14: False} (2) {126: False} (2) {238: False} (2) {247: False} (2) {256: False} (2) {8: False} (2) {11: False} (2) {142...
FunctionDef (13) AssignName (12) Name (7) ClassDef (3) Const (1) Arguments (1)
7 (5) 13 (2) 14 (2) 102 (2) 127 (2) 239 (2) 248 (2) 257 (2) 6 (2) 8 (2)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 9: 26 calls (0.0)
MessageDefinition (26)
{10: True} (3) {18: True} (3) {7: False} (3) {8: False} (2) {12: False} (2) {14: True} (2) {16: False} (2) {20: False} (2) {156: False} (1) {45: True}...
Module (26)
3 (15) 4 (6) 7 (2) 5 (2) 6 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 10: 21 calls (0.0)
MessageDefinition (21)
{7: False} (3) {89: False} (3) {116: False} (2) {133: False} (2) {11: False} (1) {12: False} (1) {158: False} (1) {84: False} (1) {96: False} (1) {87:...
FunctionDef (14) ClassDef (7)
8 (3) 90 (3) 118 (2) 134 (2) 12 (1) 13 (1) 159 (1) 85 (1) 97 (1) 88 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 11: 14 calls (0.0)
MessageDefinition (14)
{146: False} (3) {84: False} (2) {70: False} (1) {115: False} (1) {101: False} (1) {26: False} (1) {13: False} (1) {18: False} (1) {49: False} (1) {93...
ClassDef (11) FunctionDef (2) ExceptHandler (1)
148 (3) 71 (1) 85 (1) 116 (1) 102 (1) 27 (1) 14 (1) 19 (1) 50 (1) 88 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 12: 9 calls (0.0)
MessageDefinition (9)
{14: False} (2) {17: False} (1) {52: False} (1) {23: False} (1) {86: False} (1) {132: False} (1) {84: False} (1) {96: False} (1)
FunctionDef (8) ClassDef (1)
12 (3) 26 (1) 8 (1) 80 (1) 109 (1) 83 (1) 91 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 13: 9 calls (0.0)
MessageDefinition (9)
{20: True} (3) {28: False} (2) {80: False} (1) {18: False} (1) {25: False} (1) {44: False} (1)
Arguments (3) Import (2) ImportFrom (1) AssignName (1) Const (1) Name (1)
20 (3) 28 (2) 80 (1) 18 (1) 25 (1) 44 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 14: 6 calls (0.0)
MessageDefinition (6)
{4: False} (2) {38: False} (1) {125: False} (1) {44: True} (1) {59: True} (1)
If (2) TryFinally (2) For (1) TryExcept (1)
5 (2) 39 (1) 126 (1) 49 (1) 64 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 15: 4 calls (0.0)
MessageDefinition (4)
{17: False} (1) {34: True} (1) {100: True} (1) {109: False} (1)
FunctionDef (4)
12 (1) 32 (1) 91 (1) 108 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]
Path 16: 1 calls (0.0)
MessageDefinition (1)
{94: False} (1)
ClassDef (1)
95 (1)
1def _set_message_state_in_block(
2 self,
3 msg: MessageDefinition,
4 lines: dict[int, bool],
5 node: nodes.NodeNG,
6 firstchildlineno: int,
7 ) -> None:
8 """Set the state of a message in a block of lines."""
9 first = node.fromlineno
10 last = node.tolineno
11 for lineno, state in list(lines.items()):
12 original_lineno = lineno
13 if first > lineno or last < lineno:
14 continue
15 # Set state for all lines for this block, if the
16 # warning is applied to nodes.
17 if msg.scope == WarningScope.NODE:
18 if lineno > firstchildlineno:
19 state = True
20 first_, last_ = node.block_range(lineno)
21 # pylint: disable=useless-suppression
22 # For block nodes first_ is their definition line. For example, we
23 # set the state of line zero for a module to allow disabling
24 # invalid-name for the module. For example:
25 # 1. # pylint: disable=invalid-name
26 # 2. ...
27 # OR
28 # 1. """Module docstring"""
29 # 2. # pylint: disable=invalid-name
30 # 3. ...
31 #
32 # But if we already visited line 0 we don't need to set its state again
33 # 1. # pylint: disable=invalid-name
34 # 2. # pylint: enable=invalid-name
35 # 3. ...
36 # The state should come from line 1, not from line 2
37 # Therefore, if the 'fromlineno' is already in the states we just start
38 # with the lineno we were originally visiting.
39 # pylint: enable=useless-suppression
40 if (
41 first_ == node.fromlineno
42 and first_ >= firstchildlineno
43 and node.fromlineno in self._module_msgs_state.get(msg.msgid, ())
44 ):
45 first_ = lineno
46
47 else:
48 first_ = lineno
49 last_ = last
50 for line in range(first_, last_ + 1):
51 # Do not override existing entries. This is especially important
52 # when parsing the states for a scoped node where some line-disables
53 # have already been parsed.
54 if (
55 (
56 isinstance(node, nodes.Module)
57 and node.fromlineno <= line < lineno
58 )
59 or (
60 not isinstance(node, nodes.Module)
61 and node.fromlineno < line < lineno
62 )
63 ) and line in self._module_msgs_state.get(msg.msgid, ()):
64 continue
65 if line in lines: # state change in the same block
66 state = lines[line]
67 original_lineno = line
68
69 self._set_message_state_on_line(msg, line, state, original_lineno)
70
71 del lines[lineno]