google/pasta

Failed to recognize empty __init__.py

williamjamir opened this issue · 1 comments

Hello,

Running google-pasta with python 2.7 against a empty __init__.py file throws a pasta.base.annotate.AnnotationError list index out of range

Script:

import pasta
path = r'__init__.py'
with open(path) as file:
    tree = pasta.parse(file.read())

Stack:

Traceback (most recent call last):
  File "script.py", line 10, in <module>
    tree = pasta.parse(file.read())
  File "w:\william\repo_pasta\pasta\__init__.py", line 25, in parse
    annotator.visit(t)
  File "w:\william\repo_pasta\pasta\base\annotate.py", line 1042, in visit
    raise AnnotationError(e)
pasta.base.annotate.AnnotationError: list index out of range

Thanks! I overlooked this case, though not sure why it's failing. Should be simple to fix.