Static Type Analysis by Abstract Interpretation of Python Programs - Archive ouverte HAL Access content directly
Conference Papers Year :

Static Type Analysis by Abstract Interpretation of Python Programs


Python is an increasingly popular dynamic programming language, particularly used in the scientific community and well-known for its powerful and permissive high-level syntax. Our work aims at detecting statically and automatically type errors. As these type errors are exceptions that can be caught later on, we precisely track all exceptions (raised or caught). We designed a static analysis by abstract interpretation able to infer the possible types of variables, taking into account the full control-flow. It handles both typing paradigms used in Python, nominal and structural, supports Python's object model, introspection operators allowing dynamic type testing, dynamic attribute addition, as well as exception handling. We present a flow-and context-sensitive analysis with special domains to support containers (such as lists) and infer type equalities (allowing it to express parametric polymorphism). The analysis is soundly derived by abstract interpretation from a concrete semantics of Python developed by Fromherz et al. Our analysis is designed in a modular way as a set of domains abstracting a concrete collecting semantics. It has been implemented into the MOPSA analysis framework, and leverages external type annotations from the Typeshed project to support the vast standard library. We show that it scales to benchmarks a few thousand lines long, and preliminary results show it is able to analyze a small real-life command-line utility called PathPicker. Compared to previous work, it is sound, while it keeps similar efficiency and precision.
Fichier principal
Vignette du fichier
LIPIcs-ECOOP-2020-17.pdf (786.65 Ko) Télécharger le fichier
Origin : Files produced by the author(s)

Dates and versions

hal-02994000 , version 1 (07-11-2020)



Raphaël Monat, Abdelraouf Ouadjaout, Antoine Miné. Static Type Analysis by Abstract Interpretation of Python Programs. 34th European Conference on Object-Oriented Programming (ECOOP 2020), Nov 2020, Berlin (Virtual / Covid), Germany. ⟨10.4230/LIPIcs.ECOOP.2020.17⟩. ⟨hal-02994000⟩
89 View
58 Download



Gmail Facebook Twitter LinkedIn More