Serge Sans Paille - Tooling for Static Analysis of Python Programs

Explore the development of tooling for static analysis of Python programs, including GAST, Benyget, and memestra, and learn how they can be used to create more efficient linters and detect deprecated functions and variables.

Key takeaways
  • The presentation focuses on tooling for static analysis of Python programs, specifically GAST and Benyget.
  • GAST is a generic abstract syntax tree representation that is compatible with Python 2.7 to 3.9 and is not dependent on the Python version being used.
  • Benyget is a tool that allows you to compute all possible devchains (chains of definitions and uses) between function definitions and their usage in Python programs.
  • It is possible to use Benyget to write a linter that detects deprecated functions and variables in Python programs.
  • memestra is a tool that allows you to flag functions and variables as deprecated, and to compute all possible devchains for a given program.
  • memestra is compatible with GAST and can be used to write a linter that detects deprecated functions and variables in Python programs.
  • Static analysis of Python programs is difficult because of Python’s dynamic nature, but tools like GAST and Benyget can be used to write more efficient linters.
  • The presentation highlights the importance of understanding the limitations of static analysis in Python, particularly when dealing with dynamic code generation and runtime dependencies.
  • The speaker argues that writing a linter for Python requires a deep understanding of the language and its complexities, and that Benyget and memestra can be useful tools in this process.