maligree / python-ast-explorer

The code behind python-ast-explorer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

alecastle opened this issue · 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.

the tool is out of date

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