google/pasta

Docstring with \n causes AnnotationError

soupytwist opened this issue · 0 comments

repro.py

class C:
  def f1(self):
    """Doc.

    String\nwith\nnewlines.
    """
    pass

  def f2(self):
    pass
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pasta
>>> with open('repro.py', 'r') as f:
...   src = f.read()
... 
>>> t = pasta.parse(src)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pasta/__init__.py", line 25, in parse
    annotator.visit(t)
  File "pasta/base/annotate.py", line 1113, in visit
    super(AstAnnotator, self).visit(node)
  File "pasta/base/annotate.py", line 126, in visit
    super(BaseVisitor, self).visit(node)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "pasta/base/annotate.py", line 46, in wrapped
    f(self, node, *args, **kwargs)
  File "pasta/base/annotate.py", line 210, in visit_Module
    self.generic_visit(node)
  File "/usr/lib/python2.7/ast.py", line 249, in generic_visit
    self.visit(item)
  File "pasta/base/annotate.py", line 1113, in visit
    super(AstAnnotator, self).visit(node)
  File "pasta/base/annotate.py", line 126, in visit
    super(BaseVisitor, self).visit(node)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "pasta/base/annotate.py", line 89, in wrapped
    f(self, node, *args, **kwargs)
  File "pasta/base/annotate.py", line 371, in visit_ClassDef
    self.visit(stmt)
  File "pasta/base/annotate.py", line 1113, in visit
    super(AstAnnotator, self).visit(node)
  File "pasta/base/annotate.py", line 126, in visit
    super(BaseVisitor, self).visit(node)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "pasta/base/annotate.py", line 89, in wrapped
    f(self, node, *args, **kwargs)
  File "pasta/base/annotate.py", line 398, in visit_FunctionDef
    for stmt in self.indented(node, 'body'):
  File "pasta/base/annotate.py", line 1143, in indented
    'more than the outer indentation.' % lineno)
pasta.base.annotate.AnnotationError: Indent detection failed (line 1); inner indentation level is not more than the outer indentation.