My goal was different than your: I wanted make writing custom refactoring code (that's it: code that modify source code) and code that works on source code a do-able task.
I end up doing some design decisions that I haven't found elsewhere (but this field is hard to explore):
- producing json, because datastructure doesn't lie to you and potential interoperability
- nodes are responsible for the formatting within itself, in opposition with lib2to3 where a node is responsible for the formatting before itself (or after, I'm not sure anymore)
- the tree is design for the human brain instead of an interpreter/compiler (for example having list instead of recursive structures)
The project is called Baron https://github.com/pycqa/baron and was actually a mean for me to work on what really interest me: the abstraction that attempt to make writing custom refactoring a doable task https://github.com/pycqa/redbaron
Good luck with your project :)