Process, Analyze, and Transform Python Code with ASTs

Repository and slides coming soon
2-3 hours

Process, Analyze, and Transform Python Code with ASTs

You've likely used a tool like black, flake8, or ruff to lint or format your code, or a tool like sphinx to document it, but you probably do not know how they accomplish their tasks. These tools and many more use Abstract Syntax Trees (ASTs) to analyze and extract information from Python code. An AST is a representation of your code's structure that enables you to access and manipulate its different components, which is what makes it possible to automate tasks like code migrations, linting, and docstring extraction.

In this workshop, you'll learn how to use the Python standard library's ast module to parse and analyze code. Using just the standard library, we will implement a couple of common checks from scratch, which will give you an idea of how these tools work and help you build the skills and confidence to use ASTs in your own projects.


Workshop outline

Coming soon

Details will be added once they are finalized. In the meantime, you can check out my keynote on ASTs, "Build Your Own (Simple) Static Code Analyzer".


Live sessions

I have presented this workshop once. Click a location on the map to see the conference(s) I have presented this workshop at.

Click a on the map to see more information.