Skip to content

Conversation

@aiandit
Copy link

@aiandit aiandit commented Jul 16, 2023

Hi, this is a suggestion: Could we make the unparser a little bit more generic maybe:

  • allow .op to be the plain string, like "+", "*" in BinOp, UnaryOps, etc.
  • detect the node type not only by the actual type but also by some special attribute

The idea is that we can use a more generic tree structure that is easier to work with.

https://github.com/aiandit/astunparse

If you look at the other branches in our fork, you can see where this is heading, we can have ASTs with a clone method and load/save to JSON and XML, for example. If you like, we would contribute all of it to the project, also because it's obviously inspired by your code a lot, but this pull request is the set of changes that we would need to make it work with astunparse, if we would alternatively put that additional stuff into a separate package.

Tested with py27 and py39.

What do you think? Thanks in advance for considering.

Best regards

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

Successfully merging this pull request may close these issues.

2 participants