summaryrefslogtreecommitdiff
path: root/pyflakes/checker.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyflakes/checker.py')
-rw-r--r--pyflakes/checker.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 382574e..75abdc0 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -870,7 +870,19 @@ class Checker(object):
def handleDoctests(self, node):
try:
- (docstring, node_lineno) = self.getDocstring(node.body[0])
+ if hasattr(node, 'docstring'):
+ docstring = node.docstring
+
+ # This is just a reasonable guess. In Python 3.7, docstrings no
+ # longer have line numbers associated with them. This will be
+ # incorrect if there are empty lines between the beginning
+ # of the function and the docstring.
+ node_lineno = node.lineno
+ if hasattr(node, 'args'):
+ node_lineno = max([node_lineno] +
+ [arg.lineno for arg in node.args.args])
+ else:
+ (docstring, node_lineno) = self.getDocstring(node.body[0])
examples = docstring and self._getDoctestExamples(docstring)
except (ValueError, IndexError):
# e.g. line 6 of the docstring for <string> has inconsistent