adding comments

This commit is contained in:
Yuval Shimon 2021-12-07 11:00:38 +02:00
parent c78b8d1893
commit 4d6bdaac41
1 changed files with 2 additions and 0 deletions

View File

@ -149,6 +149,8 @@ def get_statement_startend2(lineno: int, node: ast.AST) -> Tuple[int, Optional[i
values: List[int] = [] values: List[int] = []
for x in ast.walk(node): for x in ast.walk(node):
if isinstance(x, (ast.stmt, ast.ExceptHandler)): if isinstance(x, (ast.stmt, ast.ExceptHandler)):
# Before Python 3.8, the lineno of a decorated class or function pointed at the decorator.
# Since Python 3.8, the lineno points to the class/def, so need to include the decorators.
if isinstance(x, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)): if isinstance(x, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)):
for d in x.decorator_list: for d in x.decorator_list:
values.append(d.lineno - 1) values.append(d.lineno - 1)