arrow
返回

Generating Python Type Annotations from Type Inference: How Far Are We?

delete2024-06-03
delete3
delete
OA
AI
Y
Yimeng Guo
Z
Zhifei Chen
L
Lin Chen *
W
Wenjie Xu
Y
Yanhui Li
B
Baowen Xu
DOI:10.1145/3652153delete
delete原文链接
delete原文求助
delete分享
delete收藏
摘要

摘要

En 中文
In recent years, dynamic languages such as Python have become popular due to their flexibility and productivity. The lack of static typing makes programs face the challenges of fixing type errors, early bug detection, and code understanding. To alleviate these issues, PEP 484 introduced optional type annotations for Python in 2014, but unfortunately, a large number of programs are still not annotated by developers. Annotation generation tools can utilize type inference techniques. However, several important aspects of type annotation generation are overlooked by existing works, such as in-depth effectiveness analysis, potential improvement exploration, and practicality evaluation. And it is unclear how far we have been and how far we can go. In this paper, we set out to comprehensively investigate the effectiveness of type inference tools for generating type annotations, applying three categories of state-of-the-art tools on a carefully-cleaned dataset. First, we use a comprehensive set of metrics and categories, finding that existing tools have different effectiveness and cannot achieve both high accuracy and high coverage. Then, we summarize six patterns to present the limitations in type annotation generation. Next, we implement a simple but effective tool to demonstrate that existing tools can be improved in practice. Finally, we conduct a controlled experiment showing that existing tools can reduce the time spent annotating types and determine more precise types, but cannot reduce subjective difficulty. Our findings point out the limitations and improvement directions in type annotation generation, which can inspire future work.
Keyword:
Type annotations
type inference
Python
empirical study

期刊

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
论文数:
1.2K
被引数:
3.4K

机构

N
nanjing university
学者数:
7.8W
论文数: 5.6W
被引数: 87
引用论文

引用论文

Bacillus Calmette-Guérin Treatment and Vesicorenal Reflux
err2017-08-11
err0
PREAI
errA. Böhle; J. Schüller; A. Knipper; A. Hofstetter
err分享
err收藏
An empirical study on the impact of static typing on software maintainability静态类型对软件可维护性影响的实证研究
err2013-12-11
err56
PREAI
errHanenberg, Stefan; Kleinschmager, Sebastian; Robbes, Romain; Tanter, Eric; Stefik, Andreas
err分享
err收藏
Activation of the mouse egg
err1996-01-01
err0
PREAI
errDouglas Kline
err分享
err收藏
学者 查看更多内容