Typify: A Lightweight Usage-driven Static Analyzer for Precise Python Type Inference

📅 2026-04-06
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the limitations of existing static type inference approaches for Python—particularly their low accuracy, poor scalability, and weak interpretability when applied to codebases lacking or partially equipped with type annotations. To overcome these challenges, the authors propose a lightweight, usage-driven static analysis method that innovatively integrates execution-aware dependency graph traversal, symbolic execution, iterative fixed-point analysis, and context-aware matching retrieval. Notably, this approach achieves high-precision type inference without relying on deep learning or large-scale datasets. Empirical evaluation demonstrates that the method significantly outperforms data-driven models such as Type4Py and HiTyper, as well as industrial tools like Pyre, on real-world benchmarks including ManyTypes4Py and Typilus, while maintaining both computational efficiency and strong interpretability.
📝 Abstract
Python's dynamic type system, while offering significant flexibility and expressiveness, poses substantial challenges for static analysis and automated tooling, particularly in unannotated or partially annotated codebases. Existing type inference approaches often depend on existing type annotations or on deep learning models that require extensive training corpora and considerable computational resources, resulting in limited scalability and reduced interpretability. We introduce Typify, a lightweight, usage-driven static analysis engine designed to infer precise and contextually relevant type information without relying on statistical learning or large datasets. Typify integrates symbolic execution with iterative fixpoint analysis and a context-matching retrieval system to propagate and predict type information across entire projects. By constructing and traversing dependency graphs in an execution-aware manner, Typify accurately connects function calls to their definitions and infers usage-based type semantics, even in complex, interdependent modules. We evaluate Typify on a diverse corpus of real-world Python repositories, including the ManyTypes4Py and Typilus datasets, benchmarking its effectiveness in predicting types of variables, arguments, and return statements. Results from the evaluation show that Typify consistently matches or surpasses state-of-the-art deep learning-based systems such as Type4Py and HiTyper, as well as industry-standard static type inference tools like Pyre. Our findings demonstrate that usage-driven, retrieval-based inference can match or exceed the accuracy of data-driven methods, offering a practical, interpretable, and computationally efficient alternative for large and evolving Python codebases.
Problem

Research questions and friction points this paper is trying to address.

Python type inference
static analysis
unannotated code
type annotation
scalability
Innovation

Methods, ideas, or system contributions that make the work stand out.

usage-driven type inference
symbolic execution
fixpoint analysis
dependency graph
static type inference
🔎 Similar Papers
No similar papers found.