python-ast-explorer icon indicating copy to clipboard operation
python-ast-explorer copied to clipboard

ast produced seems out of date w.r.t. module changes

Open alecastle opened this issue 5 years ago • 1 comments

for a simple example, the input

x.sort(reverse=True)

comes out as follows in the tool:

image

However, in the latest version of Python (3.8.1 as of this writing), the following AST is produced:

>>> ast.dump(ast.parse("x.sort(reverse=True)"))
"Module(body=[Expr(value=Call(func=Attribute(value=Name(id='x', ctx=Load()), attr='sort', ctx=Load()), args=[], keywords=[keyword(arg='reverse', value=Constant(value=True, kind=None))]))], type_ignores=[])"

That's a little hard to read, so let's look specifically at the keywords part:

keywords=[keyword(arg='reverse', value=Constant(value=True, kind=None))]

Here, the value of the keyword is an ast.Constant object, as opposed to the ast.Name object presented in the output of the tool. The documentation of the ast module is very sparse, so I'm not sure in what version this was introduced, but suffice it to say this is proof that the tool is out of date.

alecastle avatar Jan 30 '20 01:01 alecastle

the tool is out of date

atm it supports python2 only, so yeah, you are right ))

gyermolenko avatar Jan 30 '20 08:01 gyermolenko