Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astor.dump_tree doesn't populate ctx. #188

Open
stuaxo opened this issue Jun 23, 2020 · 0 comments
Open

astor.dump_tree doesn't populate ctx. #188

stuaxo opened this issue Jun 23, 2020 · 0 comments

Comments

@stuaxo
Copy link

stuaxo commented Jun 23, 2020

I've started playing with astor and ASTs, and noticed astor doesn't populate ctx when using dump_tree, this makes means there is an extra step to fill this out before the output can be used for NodeTransformer etc.

Astor dump - no ctx:

print(astor.dump_tree(parse('a = variables[1]')))
Module(
    body=[
        Assign(targets=[Name(id='a')],
            value=Subscript(value=Name(id='variables'), slice=Index(value=Constant(value=1, kind=None))),
            type_comment=None)],
    type_ignores=[])

dump_tree from greentreesnakes:

print(dump(parse('a = variables[1]')))
Module(body=[
    Assign(targets=[
        Name(id='a', ctx=Store()),
      ], value=Subscript(value=Name(id='variables', ctx=Load()), slice=Index(value=Constant(value=1, kind=None)), ctx=Load()), type_comment=None),
  ], type_ignores=[])
@stuaxo stuaxo changed the title astor.dump_tree doesn't include ctx ? astor.dump_tree doesn't populate ctx. Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant