Path 1: 545 calls (0.42)

list (545)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 2: 276 calls (0.21)

list (276)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 3: 185 calls (0.14)

list (185)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 4: 155 calls (0.12)

list (155)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 5: 129 calls (0.1)

list (129)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 6: 2 calls (0.0)

list (2)

None (2)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 7: 2 calls (0.0)

list (2)

KeyError (2)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 8: 2 calls (0.0)

list (2)

None (2)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 9: 2 calls (0.0)

list (2)

UnknownMessageError (2)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 10: 2 calls (0.0)

list (2)

UnknownMessageError (2)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 11: 1 calls (0.0)

list (1)

InvalidPragmaError (1)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 12: 1 calls (0.0)

list (1)

DeletedMessageError (1)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 13: 1 calls (0.0)

list (1)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 14: 1 calls (0.0)

list (1)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 15: 1 calls (0.0)

list (1)

KeyError (1)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue
            

Path 16: 1 calls (0.0)

list (1)

UnRecognizedOptionError (1)

1def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
2        """Process tokens from the current module to search for module/block level
3        options.
4
5        See func_block_disable_msg.py test case for expected behaviour.
6        """
7        control_pragmas = {"disable", "disable-next", "enable"}
8        prev_line = None
9        saw_newline = True
10        seen_newline = True
11        for tok_type, content, start, _, _ in tokens:
12            if prev_line and prev_line != start[0]:
13                saw_newline = seen_newline
14                seen_newline = False
15
16            prev_line = start[0]
17            if tok_type in (tokenize.NL, tokenize.NEWLINE):
18                seen_newline = True
19
20            if tok_type != tokenize.COMMENT:
21                continue
22            match = OPTION_PO.search(content)
23            if match is None:
24                continue
25            try:  # pylint: disable = too-many-try-statements
26                for pragma_repr in parse_pragma(match.group(2)):
27                    if pragma_repr.action in {"disable-all", "skip-file"}:
28                        if pragma_repr.action == "disable-all":
29                            self.linter.add_message(
30                                "deprecated-pragma",
31                                line=start[0],
32                                args=("disable-all", "skip-file"),
33                            )
34                        self.linter.add_message("file-ignored", line=start[0])
35                        self._ignore_file = True
36                        return
37                    try:
38                        meth = self._options_methods[pragma_repr.action]
39                    except KeyError:
40                        meth = self._bw_options_methods[pragma_repr.action]
41                        # found a "(dis|en)able-msg" pragma deprecated suppression
42                        self.linter.add_message(
43                            "deprecated-pragma",
44                            line=start[0],
45                            args=(
46                                pragma_repr.action,
47                                pragma_repr.action.replace("-msg", ""),
48                            ),
49                        )
50                    for msgid in pragma_repr.messages:
51                        # Add the line where a control pragma was encountered.
52                        if pragma_repr.action in control_pragmas:
53                            self._pragma_lineno[msgid] = start[0]
54
55                        if (pragma_repr.action, msgid) == ("disable", "all"):
56                            self.linter.add_message(
57                                "deprecated-pragma",
58                                line=start[0],
59                                args=("disable=all", "skip-file"),
60                            )
61                            self.linter.add_message("file-ignored", line=start[0])
62                            self._ignore_file = True
63                            return
64                            # If we did not see a newline between the previous line and now,
65                            # we saw a backslash so treat the two lines as one.
66                        l_start = start[0]
67                        if not saw_newline:
68                            l_start -= 1
69                        try:
70                            meth(msgid, "module", l_start)
71                        except (
72                            exceptions.DeletedMessageError,
73                            exceptions.MessageBecameExtensionError,
74                        ) as e:
75                            self.linter.add_message(
76                                "useless-option-value",
77                                args=(pragma_repr.action, e),
78                                line=start[0],
79                                confidence=HIGH,
80                            )
81                        except exceptions.UnknownMessageError:
82                            self.linter.add_message(
83                                "unknown-option-value",
84                                args=(pragma_repr.action, msgid),
85                                line=start[0],
86                                confidence=HIGH,
87                            )
88
89            except UnRecognizedOptionError as err:
90                self.linter.add_message(
91                    "unrecognized-inline-option", args=err.token, line=start[0]
92                )
93                continue
94            except InvalidPragmaError as err:
95                self.linter.add_message(
96                    "bad-inline-option", args=err.token, line=start[0]
97                )
98                continue