Skip to content

Commit 2738c0f

Browse files
committed
Fixing type annotations.
1 parent c105028 commit 2738c0f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

flake8_dunder_all/utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
import ast
3838
import re
3939
from textwrap import dedent, indent
40-
from typing import Optional
40+
from typing import Optional, Union
4141

4242
__all__ = ["get_docstring_lineno", "tidy_docstring"]
4343

4444

45-
def get_docstring_lineno(node: ast.AST) -> Optional[int]:
45+
def get_docstring_lineno(node: Union[ast.FunctionDef, ast.ClassDef, ast.Module]) -> Optional[int]:
4646
"""
4747
Returns the linenumber of the start of the docstring for ``node``.
4848
@@ -52,12 +52,12 @@ def get_docstring_lineno(node: ast.AST) -> Optional[int]:
5252
if not (node.body and isinstance(node.body[0], ast.Expr)):
5353
return None
5454

55-
node = node.body[0].value
55+
body = node.body[0].value
5656

57-
if isinstance(node, ast.Str):
58-
return node.lineno
59-
elif isinstance(node, ast.Constant) and isinstance(node.value, str):
60-
return node.lineno # pragma: no cover
57+
if isinstance(body, ast.Str):
58+
return body.lineno
59+
elif isinstance(body, ast.Constant) and isinstance(body.value, str):
60+
return body.lineno # pragma: no cover
6161
else:
6262
return None
6363

0 commit comments

Comments
 (0)