paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Where to Start: Studying Type Annotation Practices in Python

从何开始:研究 Python 中的类型注解实践
ASE 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)2021匹配度 2/10 · 该论文研究 Python 类型注解的实证模式与文件优先注解建议,属于类型系统/渐进类型与软件工程实证研究,与用户关注的 PL↔AI、静态分析用于 ML/Agentic 程序、LLM/Agent 改进静态分析、浮点或贝叶斯程序分析等核心方向没有直接交集。引用 11 inbox
Wuxia Jin, Dinghong Zhong, Zifan Ding, Ming Fan, Ting Liu
crossref: 2026-09-12

AI 速览

一句话:通过实证研究总结 Python 类型注解的六种非平凡模式与三类文件特征,并给出优先注解建议。

动态语言正逐步引入渐进类型,允许源码中可选类型注解,但为大型长期维护的代码库添加类型注解是一个渐进且昂贵的过程。开发者面临两个问题:缺乏如何实现类型注解的指导,以及缺乏应先注解代码库哪些部分的指导。本文研究 Python 中非平凡类型注解实践的模式,以及已类型注解代码文件的特征。研究识别出六种类型注解实践模式,它们涉及恢复和表达设计关注点;同时揭示已注解文件的三个互补特征。作者还实现了一个用于研究可选类型实践的工具。基于此,作者建议:实现类型注解时至少应遵循六种模式并考虑设计关注点;对软件架构至关重要的文件可优先添加类型注解。

问题
动态语言采用渐进类型后,开发者缺乏关于如何实现类型注解以及应优先注解代码库哪些部分的指导。
方法
对 Python 代码库中的非平凡类型注解实践和已类型注解文件特征进行实证研究,并实现一个用于研究可选类型实践的工具。
评估
通过实证分析识别出六种类型注解模式和三个互补的文件特征,并据此提出优先注解软件架构关键文件等实践建议。
原文摘要(Abstract)

Dynamic programming languages have been embracing gradual typing, which supports optional type annotations in source code. Type-annotating a complex and long-lasting codebase is indeed a gradual and expensive process, where two issues have troubled developers. First, there is few guidance about how to implement type annotations due to the existence of non-trivial type practices; second, there is few guidance about which portion of a codebase should be type-annotated first. To address these issues, this paper investigates the patterns of non-trivial type-annotation practices and features of type-annotated code files. Our study detected six patterns of type-annotation practices, which involve recovering and expressing design concerns. Moreover, we revealed three complementary features of type-annotated files. Besides, we implemented a tool for studying optional typing practice. We suggest that: 1) design concerns should be considered to improve type annotation implementation by following at least six patterns; 2) files critical to software architecture could be type-annotated in priority. We believe these guidelines would promote a better type annotation practice for dynamic languages.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot6543,
  title = {Where to Start: Studying Type Annotation Practices in Python},
  author = {Wuxia Jin and Dinghong Zhong and Zifan Ding and Ming Fan and Ting Liu},
  booktitle = {ASE},
  year = {2021},
  doi = {10.1109/ase51524.2021.9678947}
}