What if you could refactor your entire code base, safely and automatically? How much old code could you fix or replace if you didn’t need to worry about updating every reference by hand? I’ll show you how a concrete syntax tree (CST) can help you do just that using only the standard Python library.
Python includes a concrete syntax tree (CST) in the standard library, useful for mass refactoring code bases of all sizes. I’ll walk through the differences between abstract and concrete syntax trees (AST and CST), why a CST is useful for refactoring, and how you can build basic refactoring tools on top of a CST to modify your entire code base quickly and safely. Lastly, I’ll demonstrate what’s possible with these tools, including upgrading code to new interfaces, or wholesale movement of code between modules.
Presented at PyCon Australia 2018 in Sydney: https://youtu.be/9USGh4Uy-xQ