Result: Principled and practical static analysis for python

Title:
Principled and practical static analysis for python
Contributors:
Milanova, Ana, Hendler, James, A., Slota, George, M., Dolby, Julian
Publisher Information:
Rensselaer Polytechnic Institute, Troy, NY
Publication Year:
2024
Subject Terms:
Document Type:
Dissertation/ Thesis thesis
File Description:
application/pdf
Language:
English
Relation:
Dept. of Computer Science; Rensselaer Theses and Dissertations Online Collection; https://hdl.handle.net/20.500.13015/7007
Rights:
This electronic version is a licensed copy owned by Rensselaer Polytechnic Institute (RPI), Troy, NY. Copyright of original work retained by author. ; Users may download and share copies with attribution in accordance with a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 license. No commercial use or derivatives are permitted without the explicit approval of the author.
Accession Number:
edsbas.615022E4
Database:
BASE

Further Information

December 2024 ; School of Science ; Python is a popular dynamic language for data science and machine learning, and is increasingly adopted for large and complex programming tasks; however, static analysis tools to support software quality and productivity are largely lacking.In programming languages type systems are the most fundamental form of static analysis. Therefore, we first embark on a study to understand the current state of Python type systems. We perform a large-scale empirical study of Python 3 types, usage of types by developers, and two popular static type checking tools, MyPy and PyType. The study shows that Python 3 types are not widely used, and that existing type systems tend to disagree with each other and with user annotations. It demonstrates the need to further study and develop types and type inference analyses as well as deeper and automatic static analyses to support Python development. The result of the study on Python 3 types motivates the remainder of this thesis. We create a principled approach for static analysis for Python with the initial goal of improving type inference analysis and later applying the concept to other client static analyses. Our approach to static analysis for Python requires analysis formalization into two phases: (1) syntax and (2) interpretation semantics. Given a specific static analysis, analysis designers first define a subset of Python syntax called PetPy that specifies explicitly what Python constructs are interpreted precisely and what constructs are interpreted approximately. The designers then define interpretation over these syntactic constructs as needed by the specific analysis. The novelty of our approach is the separation of precisely-interpreted constructs from approximately-interpreted ones, thus making analysis approximation, unavoidable in Python, explicit. Following the principled and practical static analysis approach, we build three novel static analyses for Python: (1) a reference immutability analysis, (2) an interprocedural weakest ...