You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trailing comma is not allowed in import, but when inside parentheses it's valid syntax
I know that this one can sound too specific, but still a valid syntax =)
file:
from foo.a import (do,)
do()
Script:
import pasta
from pasta.augment import rename
path = r'test.py'
with open(path) as file:
tree = pasta.parse(file.read())
Full stack trace
Traceback (most recent call last):
File "script.py", line 8, in <module>
tree = pasta.parse(file.read())
File "/opt/pasta/pasta/__init__.py", line 25, in parse
annotator.visit(t)
File "/opt/pasta/pasta/base/annotate.py", line 1055, in visit
super(AstAnnotator, self).visit(node)
File "/opt/pasta/pasta/base/annotate.py", line 115, in visit
super(BaseVisitor, self).visit(node)
File "/home/william/miniconda3/envs/google_pasta_py27/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/opt/pasta/pasta/base/annotate.py", line 79, in wrapped
f(self, node, *args, **kwargs)
File "/opt/pasta/pasta/base/annotate.py", line 168, in visit_Module
self.generic_visit(node)
File "/home/william/miniconda3/envs/google_pasta_py27/lib/python2.7/ast.py", line 249, in generic_visit
self.visit(item)
File "/opt/pasta/pasta/base/annotate.py", line 1055, in visit
super(AstAnnotator, self).visit(node)
File "/opt/pasta/pasta/base/annotate.py", line 115, in visit
super(BaseVisitor, self).visit(node)
File "/home/william/miniconda3/envs/google_pasta_py27/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/opt/pasta/pasta/base/annotate.py", line 43, in wrapped
f(self, node, *args, **kwargs)
File "/opt/pasta/pasta/base/annotate.py", line 520, in visit_Expr
self.visit(node.value)
File "/opt/pasta/pasta/base/annotate.py", line 1055, in visit
super(AstAnnotator, self).visit(node)
File "/opt/pasta/pasta/base/annotate.py", line 115, in visit
super(BaseVisitor, self).visit(node)
File "/home/william/miniconda3/envs/google_pasta_py27/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/opt/pasta/pasta/base/annotate.py", line 43, in wrapped
f(self, node, *args, **kwargs)
File "/opt/pasta/pasta/base/annotate.py", line 637, in visit_Call
self.visit(node.func)
File "/opt/pasta/pasta/base/annotate.py", line 1055, in visit
super(AstAnnotator, self).visit(node)
File "/opt/pasta/pasta/base/annotate.py", line 115, in visit
super(BaseVisitor, self).visit(node)
File "/home/william/miniconda3/envs/google_pasta_py27/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/opt/pasta/pasta/base/annotate.py", line 43, in wrapped
f(self, node, *args, **kwargs)
File "/opt/pasta/pasta/base/annotate.py", line 754, in visit_Name
self.token(node.id)
File "/opt/pasta/pasta/base/annotate.py", line 1118, in token
token_val, token.src, token.start[0], token.line))
pasta.base.annotate.AnnotationError: Expected 'do' but found ','
line 1: from foo.a import (do,)
Fixes#24.
Some statements can have parenthesized parts within them that are more
than a single sub-expression, and these may also have a trailing comma.
To handle these cases, I'm generalizing the "scope" function again to
include a trailing comma optionally.
Fixes#24.
Some statements can have parenthesized parts within them that are more
than a single sub-expression, and these may also have a trailing comma.
To handle these cases, I'm generalizing the "scope" function again to
include a trailing comma optionally.
…#28)
Handle parenthesized parts of statements with optional trailing comma
Fixes#24.
Some statements can have parenthesized parts within them that are more
than a single sub-expression, and these may also have a trailing comma.
To handle these cases, I'm generalizing the "scope" function again to
include a trailing comma optionally.
Hi,
Trailing comma is not allowed in import, but when inside parentheses it's valid syntax
I know that this one can sound too specific, but still a valid syntax =)
file:
Script:
Full stack trace
cc @nicoddemus
The text was updated successfully, but these errors were encountered: