Skip to content

Commit 3fc62b7

Browse files
committed
Use correct line number with decorators on Python 3.8
1 parent 05e2072 commit 3fc62b7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

flake8_missing_annotations/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
# stdlib
3030
import ast
31+
import sys
3132
import textwrap
3233
from typing import Any, Generator, Iterable, List, NamedTuple, Optional, Tuple, Type
3334

@@ -260,10 +261,16 @@ def visit_FunctionDef(self, function: ast.FunctionDef) -> None:
260261
if self._state:
261262
function_name = '.'.join((*self._state, function_name))
262263

264+
function_lineno = function.lineno
265+
266+
if sys.version_info < (3, 8):
267+
# TODO: account for multiline decorators
268+
function_lineno += len(decorators)
269+
263270
error = Error(
264271
function_name,
265272
offending_arguments,
266-
function.lineno + len(decorators),
273+
function_lineno,
267274
function.col_offset,
268275
)
269276
self._errors.append(error)

0 commit comments

Comments
 (0)