check_spelling: correct line numbers for Python extraction

This commit is contained in:
Campbell Barton
2023-09-05 10:49:17 +10:00
parent 9f8d062de4
commit 0cfa9dcec1
+2 -2
View File
@@ -354,11 +354,11 @@ def extract_py_comments(filepath: str) -> Tuple[List[Comment], Set[str]]:
for toktype, ttext, (slineno, scol), (elineno, ecol), ltext in tokgen:
if toktype == token.STRING:
if prev_toktype == token.INDENT:
comments.append(Comment(filepath, ttext, slineno, 'DOCSTRING'))
comments.append(Comment(filepath, ttext, slineno - 1, 'DOCSTRING'))
elif toktype == tokenize.COMMENT:
# non standard hint for commented CODE that we can ignore
if not ttext.startswith("#~"):
comments.append(Comment(filepath, ttext, slineno, 'COMMENT'))
comments.append(Comment(filepath, ttext, slineno - 1, 'COMMENT'))
else:
for match in re_vars.finditer(ttext):
code_words.add(match.group(0))