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 条
  • [21] How Well Static Type Checkers Work with Gradual Typing? A Case Study on Python']Python
    Xu, Wenjie
    Chen, Lin
    Su, Chenghao
    Guo, Yimeng
    Li, Yanhui
    Zhou, Yuming
    Xu, Baowen
    2023 IEEE/ACM 31ST INTERNATIONAL CONFERENCE ON PROGRAM COMPREHENSION, ICPC, 2023, : 242 - 253
  • [22] Towards a type-based abstract semantics for Python']Python
    Nacu, Andrei
    JOURNAL OF LOGICAL AND ALGEBRAIC METHODS IN PROGRAMMING, 2025, 143
  • [23] DLInfer: Deep Learning with Static Slicing for Python']Python Type Inference
    Yan, Yanyan
    Feng, Yang
    Fan, Hongcheng
    Xu, Baowen
    2023 IEEE/ACM 45TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING, ICSE, 2023, : 2009 - 2021
  • [24] Empirical Study of the Evolution of Python']Python Questions on Stack Overflow
    Syam, Gopika
    Lal, Sangeeta
    Chen, Tao
    E-INFORMATICA SOFTWARE ENGINEERING JOURNAL, 2023, 17 (01)
  • [25] Systems Neuroscience Computing in Python']Python (SyNCoPy): a python']python package for large-scale analysis of electrophysiological data
    Moenke, Gregor
    Schaefer, Tim
    Parto-Dezfouli, Mohsen
    Kajal, Diljit Singh
    Fuertinger, Stefan
    Schmiedt, Joscha Tapani
    Fries, Pascal
    FRONTIERS IN NEUROINFORMATICS, 2024, 18
  • [26] Towards an understanding of memory leak patterns: an empirical study in Python
    Jie Chen
    Dongjin Yu
    Haiyang Hu
    Software Quality Journal, 2023, 31 : 1303 - 1330
  • [27] An empirical study of automated unit test generation for Python']Python
    Lukasczyk, Stephan
    Kroiss, Florian
    Fraser, Gordon
    EMPIRICAL SOFTWARE ENGINEERING, 2023, 28 (02)
  • [28] An Empirical Study on Python']Python Library Dependency and Conflict Issues
    Jia, Xinyu
    Thou, Yu
    Hussain, Yasir
    Yang, Wenhua
    2024 IEEE 24TH INTERNATIONAL CONFERENCE ON SOFTWARE QUALITY, RELIABILITY AND SECURITY, QRS, 2024, : 504 - 515
  • [29] Risky Dynamic Typing-related Practices in Python']Python: An Empirical StudyRisky Dynamic Typing-related Practices in Python']Python: An Empirical Study
    Chen, Zhifei
    Chen, Lin
    Yang, Yibiao
    Feng, Qiong
    Li, Xuansong
    Song, Wei
    ACM TRANSACTIONS ON SOFTWARE ENGINEERING AND METHODOLOGY, 2024, 33 (06)
  • [30] Using GitHub Copilot for Test Generation in Python']Python: An Empirical Study
    El Haji, Khalid
    Brandt, Carolin
    Zaidman, Andy
    PROCEEDINGS OF THE 2024 IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATION OF SOFTWARE TEST, AST 2024, 2024, : 45 - 55