Static Type Recommendation for Python
Ke Sun, Yifan Zhao, Dan Hao, Lu Zhang
Abstract
Recently, Python has adopted optional type annotation to support type checking and program documentation. However, to enjoy the benefits, developers have to manually write type annotations, which is recognized to be a time-consuming task. To alleviate human efforts on manual type annotation, machine-learning-based approaches have been proposed to recommend types based on code features. However, they suffer from the correctness problem, i.e., the recommended types cannot pass type checking. To address the correctness problem of the machine-learning-based approaches, in this paper, we present a static type recommendation approach, named Stray. Stray can recommend types correctly. We evaluate Stray by comparing it against four state-of-art type recommendation approaches, and find that Stray outperforms these baselines by over 30% absolute improvement in both precision and recall.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Your agent calls
Lunesearch_papers
Free to start. No credit card required.
Terminal
Install the CLIlune papers get b2538051-76ec-4e75-8719-bde4db098b1aCited by top-tier papers2
- Domain Knowledge Matters: Improving Prompts with Fix Templates for Repairing Python Type ErrorsYun Peng, Shuzheng Gao, Cuiyun Gao, Yintong Huo et al.ICSE 2024 · 39 citations
- QuAC: Quick Attribute-Centric Type Inference for PythonJifeng Wu, Caroline LemieuxOOPSLA 2024 · 2 citations
Related papers
- Automating Just-In-Time Python Type Annotation UpdatingZhipeng Xue, Zhipeng Gao, Xing Hu, Jingyuan Chen et al.ICSE 2026
- Type4Py: Practical Deep Similarity Learning-Based Type Inference for PythonAmir M. Mir, Evaldas Latoskinas, Sebastian Proksch, Georgios GousiosICSE 2022 · 59 citations
- DLInfer: Deep Learning with Static Slicing for Python Type InferenceYanyan Yan, Yang Feng, Hongcheng Fan, Baowen XuICSE 2023 · 9 citations
- Static Inference Meets Deep learning: A Hybrid Type Inference Approach for PythonYun Peng, Cuiyun Gao, Zongjie Li, Bowei Gao et al.ICSE 2022 · 48 citations
- PyTER: effective program repair for Python type errorsWonseok Oh, Hakjoo OhFSE 2022 · 22 citations
