Towards a Large -Scale Empirical Study of Python']Python Static Type Annotations

被引:0
|
作者
Lin, Xinrong [1 ]
Hua, Baojian [1 ]
Wang, Yang [1 ]
Pan, Zhizhong [1 ]
机构
[1] Univ Sci & Technol China, Sch Software Engn, Hefei, Peoples R China
基金
中国国家自然科学基金;
关键词
Empirical Study; !text type='Python']Python[!/text; Static Type Annotations; BUG-DENSITY; IMPACT;
D O I
10.1109/SANER56733.2023.00046
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Python, as one of the most popular and important programming languages in the era of data science, has recently introduced a syntax for static type annotations with PEP 484, to improve code maintainability, quality, and readability. However, it is still unknown whether and how static type annotations are used in practical Python projects. This paper presents, to the best of our knowledge, the first and most comprehensive empirical study on the defects, evolution and rectification of static type annotations in Python projects. We first designed and implemented a software prototype dubbed PYSCAN, then used it to scan notable Python projects with diverse domains and sizes and type annotation manners, which add up to 19,478,428 lines of Python code. The empirical results provide interesting findings and insights, such as: 1) we proposed a taxonomy of Python type annotation-related defects, by classifying defects into four categories; 2) we investigated the evolution of type annotation-related defects; and 3) we proposed automatic defect rectification strategies, generating rectification suggestions for 82 out of 110 (74.55%) defects successfully. We suggest that: 1) Python language designers should clarify the type annotation specification; 2) checking tool builders should improve their tools to suppress false positives; and 3) Python developers should integrate such checking tools into their development workflow to catch type annotation-related defects at an early development stage. We have reported our findings and suggestions to Python language designers, checking tool builders, and Python developers. They have acknowledged us and taken actions based on our suggestions. We believe these guidelines would improve static type annotation practices and benefit the Python ecosystem in general.
引用
收藏
页码:414 / 425
页数:12
相关论文
共 50 条
  • [1] The Evolution of Type Annotations in Python']Python: An Empirical Study
    Di Grazia, Luca
    Pradel, Michael
    PROCEEDINGS OF THE 30TH ACM JOINT MEETING EUROPEAN SOFTWARE ENGINEERING CONFERENCE AND SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING, ESEC/FSE 2022, 2022, : 209 - 220
  • [2] Static Type Analysis for Python']Python
    Dong, Tiancong
    Chen, Lin
    Xu, Zhaogui
    Yu, Bin
    2014 11TH WEB INFORMATION SYSTEM AND APPLICATION CONFERENCE (WISA), 2014, : 65 - 68
  • [3] Static Type Recommendation for Python']Python
    Sun, Ke
    Zhao, Yifan
    Hao, Dan
    Zhang, Lu
    PROCEEDINGS OF THE 37TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING, ASE 2022, 2022,
  • [4] Enabling Empirical Research: A Corpus of Large-Scale Python']Python Systems
    Omari, Safwan
    Martinez, Gina
    PROCEEDINGS OF THE FUTURE TECHNOLOGIES CONFERENCE (FTC) 2019, VOL 2, 2020, 1070 : 661 - 669
  • [5] Towards an understanding of memory leak patterns: an empirical study in Python']Python
    Chen, Jie
    Yu, Dongjin
    Hu, Haiyang
    SOFTWARE QUALITY JOURNAL, 2023, 31 (04) : 1303 - 1330
  • [6] An Empirical Study of Type-Related Defects in Python']Python Projects
    Khan, Faizan
    Chen, Boqi
    Varro, Daniel
    McIntosh, Shane
    IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 2022, 48 (08) : 3145 - 3158
  • [7] Static Type Inference for Foreign Functions of Python']Python
    Hu, Mingzhe
    Zhang, Yu
    Huang, Wenchao
    Xiong, Yan
    2021 IEEE 32ND INTERNATIONAL SYMPOSIUM ON SOFTWARE RELIABILITY ENGINEERING (ISSRE 2021), 2021, : 423 - 433
  • [8] A Large-Scale Security-Oriented Static Analysis of Python']Python Packages in PyPI
    Ruohonen, Jukka
    Hjerppe, Kalle
    Rindell, Kalle
    2021 18TH INTERNATIONAL CONFERENCE ON PRIVACY, SECURITY AND TRUST (PST), 2021,
  • [9] Generating Python']Python Type Annotations from Type Inference: How Far Are We?
    Guo, Yimeng
    Chen, Zhifei
    Chen, Lin
    Xu, Wenjie
    Li, Yanhui
    Zhou, Yuming
    Xu, Baowen
    ACM TRANSACTIONS ON SOFTWARE ENGINEERING AND METHODOLOGY, 2024, 33 (05)
  • [10] Empirical Study of Python']Python Call Graph
    Li, Yu
    34TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING (ASE 2019), 2019, : 1274 - 1276