for work, i wrote a tool that takes an astroid AST tree and translates it into XML (in memory), which are very close in spirit since they're both tree-like structures. this lets one write linter tools using familiar XPath queries and assert on the results. it's good for some kinds of pattern/anti-pattern enforcement.
https://pylint.pycqa.org/projects/astroid/en/latest/index.ht...