The evolution of type annotations in python: an empirical study
Luca Di Grazia, Michael Pradel
摘要
Type annotations and gradual type checkers attempt to reveal errors and facilitate maintenance in dynamically typed programming languages. Despite the availability of these features and tools, it is currently unclear how quickly developers are adopting them, what strategies they follow when doing so, and whether adding type annotations reveals more type errors. This paper presents the first large-scale empirical study of the evolution of type annotations and type errors in Python. The study is based on an analysis of 1,414,936 type annotation changes, which we extract from 1,123,393 commits among 9,655 projects. Our results show that (i) type annotations are getting more popular, and once added, often remain unchanged in the projects for a long time, (ii) projects follow three evolution patterns for type annotation usage -- regular annotation, type sprints, and occasional uses -- and that the used pattern correlates with the number of contributors, (iii) more type annotations help find more type errors (0.704 correlation), but nevertheless, many commits (78.3%) are committed despite having such errors. Our findings show that better developer training and automated techniques for adding type annotations are needed, as most code still remains unannotated, and they call for a better integration of gradual type checking into the development process.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 10 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- DyPyBench: A Benchmark of Executable Python Software 引用了 Typilus: neural type hints
- DyPyBench: A Benchmark of Executable Python Software 引用了 DynaPyt: a dynamic analysis framework for Python
- DyPyBench: A Benchmark of Executable Python Software 引用了 TypeWriter: neural type prediction with search-based validation
- PyTy: Repairing Static Type Errors in Python 引用了 Typilus: neural type hints
- PyTy: Repairing Static Type Errors in Python 引用了 TypeWriter: neural type prediction with search-based validation
- Towards Effective Static Type-Error Detection for Python 引用了 Typilus: neural type hints
- Towards Effective Static Type-Error Detection for Python 引用了 DynaPyt: a dynamic analysis framework for Python
- Towards Effective Static Type-Error Detection for Python 引用了 TypeWriter: neural type prediction with search-based validation
- DyLin: A Dynamic Linter for Python 引用了 Typilus: neural type hints
- DyLin: A Dynamic Linter for Python 引用了 DyPyBench: A Benchmark of Executable Python Software
- DyLin: A Dynamic Linter for Python 引用了 DynaPyt: a dynamic analysis framework for Python
- DyLin: A Dynamic Linter for Python 引用了 TypeWriter: neural type prediction with search-based validation
引用它的顶会 Paper10
- PyTy: Repairing Static Type Errors in PythonYiu Wai Chow, Luca Di Grazia, Michael PradelICSE 2024 · 13 次引用
- DyPyBench: A Benchmark of Executable Python SoftwareIslem Bouzenia, Bajaj Piyush Krishan, Michael PradelFSE 2024 · 8 次引用
- Are Prompt Engineering and TODO Comments Friends or Foes? An Evaluation on GitHub CopilotDavid O'Brien, Sumon Biswas, Sayem Mohammad Imtiaz, Rabe Abdalkareem 等ICSE 2024 · 7 次引用
- Towards Effective Static Type-Error Detection for PythonWonseok Oh, Hakjoo OhASE 2024 · 1 次引用
- DyLin: A Dynamic Linter for PythonAryaz Eghbali, Felix Burk, Michael PradelFSE 2025 · 1 次引用
它引用的 Paper8
- Freezing the Web: A Study of ReDoS Vulnerabilities in JavaScript-based Web ServersCristian-Alexandru Staicu, Michael PradelUSENIX Security 2018 · 125 次引用
- TypeWriter: neural type prediction with search-based validationMichael Pradel, Georgios Gousios, Jason Liu, Satish ChandraFSE 2020 · 102 次引用
- Typilus: neural type hintsMiltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng GaoPLDI 2020 · 92 次引用
- CodeShovel: Constructing Method-Level Source Code HistoriesFelix Grund, Shaiful Alam Chowdhury, Nick C. Bradley, Braxton Hall 等ICSE 2021 · 33 次引用
- DynaPyt: a dynamic analysis framework for PythonAryaz Eghbali, Michael PradelFSE 2022 · 30 次引用
相关 Paper
- Where to Start: Studying Type Annotation Practices in PythonWuxia Jin, Dinghong Zhong, Zifan Ding, Ming Fan 等ASE 2021 · 10 次引用
- An Empirical Study of Suppressed Static Analysis WarningsHuimin Hu, Yingying Wang, Julia Rubin, Michael PradelFSE 2025 · 1 次引用
- Taming type annotations in gradual typingJohn Peter Campora III, Sheng ChenOOPSLA 2020 · 7 次引用
- Typed and Confused: Studying the Unexpected Dangers of Gradual TypingDominic Troppmann, Aurore Fass, Cristian-Alexandru StaicuASE 2024 · 2 次引用
- Automating Just-In-Time Python Type Annotation UpdatingZhipeng Xue, Zhipeng Gao, Xing Hu, Jingyuan Chen 等ICSE 2026
