|
14 | 14 |
|
15 | 15 | from pylint.checkers import BaseRawFileChecker, BaseTokenChecker
|
16 | 16 | from pylint.typing import ManagedMessage
|
17 |
| -from pylint.utils.pragma_parser import OPTION_PO, PragmaParserError, parse_pragma |
18 | 17 |
|
19 | 18 | if TYPE_CHECKING:
|
20 | 19 | from pylint.lint import PyLinter
|
@@ -134,45 +133,16 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
|
134 | 133 | """Inspect the source to find fixme problems."""
|
135 | 134 | if not self.linter.config.notes:
|
136 | 135 | return
|
137 |
| - comments = ( |
138 |
| - token_info for token_info in tokens if token_info.type == tokenize.COMMENT |
139 |
| - ) |
140 |
| - for comment in comments: |
141 |
| - comment_text = comment.string[1:].lstrip() # trim '#' and white-spaces |
142 |
| - |
143 |
| - # handle pylint disable clauses |
144 |
| - disable_option_match = OPTION_PO.search(comment_text) |
145 |
| - if disable_option_match: |
146 |
| - try: |
147 |
| - values = [] |
148 |
| - try: |
149 |
| - for pragma_repr in ( |
150 |
| - p_rep |
151 |
| - for p_rep in parse_pragma(disable_option_match.group(2)) |
152 |
| - if p_rep.action == "disable" |
153 |
| - ): |
154 |
| - values.extend(pragma_repr.messages) |
155 |
| - except PragmaParserError: |
156 |
| - # Printing useful information dealing with this error is done in the lint package |
157 |
| - pass |
158 |
| - except ValueError: |
159 |
| - self.add_message( |
160 |
| - "bad-inline-option", |
161 |
| - args=disable_option_match.group(1).strip(), |
162 |
| - line=comment.start[0], |
163 |
| - ) |
164 |
| - continue |
165 |
| - self.linter.add_ignored_message("fixme", line=comment.start[0]) |
| 136 | + for token_info in tokens: |
| 137 | + if token_info.type != tokenize.COMMENT: |
166 | 138 | continue
|
167 |
| - |
168 |
| - # emit warnings if necessary |
169 |
| - match = self._fixme_pattern.search("#" + comment_text.lower()) |
170 |
| - if match: |
| 139 | + comment_text = token_info.string[1:].lstrip() # trim '#' and white-spaces |
| 140 | + if self._fixme_pattern.search("#" + comment_text.lower()): |
171 | 141 | self.add_message(
|
172 | 142 | "fixme",
|
173 |
| - col_offset=comment.start[1] + 1, |
| 143 | + col_offset=token_info.start[1] + 1, |
174 | 144 | args=comment_text,
|
175 |
| - line=comment.start[0], |
| 145 | + line=token_info.start[0], |
176 | 146 | )
|
177 | 147 |
|
178 | 148 |
|
|
0 commit comments