paperbot · PL 论文追踪

全部论文 待读 收藏

P2 The evolution of type annotations in python: an empirical study

Python 中类型注解的演化:一项实证研究
FSE Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2022匹配度 2/10 · 论文是 Python 类型注解演化的实证研究,属于类型系统与开发者工具方向,但与用户核心关注的 PL→AI、AI→PL、浮点程序分析、贝叶斯程序分析及 LLM/Agent 交叉均无直接关系。它不涉及机器学习系统、Agentic 程序、LLM 改进静态分析或工业落地工具。引用 28 inbox
Luca Di Grazia, Michael Pradel
crossref: 2026-09-12

AI 速览

一句话:首次大规模实证研究 Python 类型注解的演化,揭示其采用模式、与类型错误的关系及开发者实践问题。

动态类型语言中的类型注解与渐进类型检查器旨在暴露错误并便于维护,但开发者采用速度、策略以及注解是否真正揭示更多类型错误尚不明确。本文对 Python 类型注解与类型错误的演化进行首次大规模实证研究,从 9,655 个项目的 1,123,393 次提交中提取 1,414,936 处类型注解变更。结果表明:(i) 类型注解日益流行,且一旦添加往往长期不变;(ii) 项目呈现三种演化模式——规律注解、type sprints 与偶发使用,且模式与贡献者数量相关;(iii) 更多注解有助于发现更多类型错误(相关性 0.704),但仍有 78.3% 的提交在存在类型错误时被提交。研究呼吁加强开发者培训、发展自动添加注解的技术,并将渐进类型检查更好地集成到开发流程中。

问题
在动态类型语言中,尽管已有类型注解与渐进类型检查器,但不清楚开发者采用它们的速度、采用的策略,以及添加类型注解是否确实能揭示更多类型错误。
方法
从 9,655 个 Python 项目、1,123,393 次提交中提取 1,414,936 处类型注解变更,进行大规模实证分析,考察注解演化模式、贡献者数量、类型错误数量及提交行为。
评估
通过统计相关性分析发现:注解使用与类型错误数量呈 0.704 相关,但 78.3% 的提交仍带有类型错误;项目演化模式与贡献者数量相关,且多数代码仍未被注解。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot6975,
  title = {The evolution of type annotations in python: an empirical study},
  author = {Luca Di Grazia and Michael Pradel},
  booktitle = {FSE},
  year = {2022},
  doi = {10.1145/3540250.3549114}
}