3 ms·
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 stru
by dimator 4y ago
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.html https://pylint.pycqa.org/projects/astroid/en/latest/index.ht...
- anitil 4y agoThat's a clever way of leveraging existing tooling! I hadn't heard of astroid before, I've always used the built in ast module
- bdg 4y agoJust curious, what do you use the resultant XML for? Analysis? Rewriting code?
- dimator 4y agono rewrites (the AST->XML bridging is one way), we use it for checking for forbidden patterns that we don't want developers using.