google / pasta

Library to refactor python code through AST manipulation.
Apache License 2.0
341 stars 40 forks source link

Missing support for relative imports over direct ancestor #56

Closed mmv closed 5 years ago

mmv commented 5 years ago

✔ Works:

import pasta
tree = pasta.parse('from .uncle.package import foo')

✔ Works:

import pasta
tree = pasta.parse('from ..granduncle.package import foo')

❌ Fails:

import pasta
tree = pasta.parse('from ...greatgranduncle.package import foo')

with error AnnotationError: Expected '.' but found '...'

soupytwist commented 5 years ago

Seems to affect python3 only, my guess is that the py2 tokenizer splits the level into three separate . tokens but py3 combines them into one.

Thanks for reporting! Will have a fix soon.