Skip to content

Commit

Permalink
Support Python 3.7
Browse files Browse the repository at this point in the history
This fixes #271.
  • Loading branch information
myint committed May 29, 2017
1 parent 821a069 commit 6118592
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,19 @@ def handleNode(self, node, parent):

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
Expand Down

0 comments on commit 6118592

Please sign in to comment.