An Empirical Study of Type-Related Defects in Python']Python Projects

被引:6
|
作者
Khan, Faizan [1 ]
Chen, Boqi [1 ]
Varro, Daniel [1 ]
McIntosh, Shane [2 ]
机构
[1] McGill Univ, Dept Elect & Comp Engn, Montreal, PQ H3A 0G4, Canada
[2] Univ Waterloo, David R Cheriton Sch Comp Sci, Waterloo, ON N2L 3G1, Canada
关键词
!text type='Python']Python[!/text; Annotations; Tools; Task analysis; Ecosystems; Software systems; Software measurement; Software defects; static type checkers; dynamic type systems; empirical study; DYNAMIC TYPE SYSTEMS;
D O I
10.1109/TSE.2021.3082068
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
In recent years, Python has experienced an explosive growth in adoption, particularly among open source projects. While Python's dynamically-typed nature provides developers with powerful programming abstractions, that same dynamic type system allows for type-related defects to accumulate in code bases. To aid in the early detection of type-related defects, type annotations were introduced into the Python ecosystem (i.e., PEP-484) and static type checkers like mypy have appeared on the market. While applying a type checker like mypy can in theory help to catch type-related defects before they impact users, little is known about the real impact of adopting a type checker to reveal defects in Python projects. In this paper, we study the extent to which Python projects benefit from such type checking features. For this purpose, we mine the issue tracking and version control repositories of 210 Python projects on GitHub. Inspired by the work of Gao et al. on type-related defects in JavaScript, we add type annotations to test whether mypy detects an error that would have helped developers to avoid real defects. We observe that 15 percent of the defects could have been prevented by mypy. Moreover, we find that there is no significant difference between the experience level of developers committing type-related defects and the experience of developers committing defects that are not type-related. In addition, a manual analysis of the anti-patterns that most commonly lead to type-checking faults reveals that the redefinition of Python references, dynamic attribute initialization and incorrectly handled Null objects are the most common causes of type-related faults. Since our study is conducted on fixed public defects that have gone through code reviews and multiple test cycles, these results represent a lower bound on the benefits of adopting a type checker. Therefore, we recommend incorporating a static type checker like mypy into the development workflow, as not only will it prevent type-related defects but also mitigate certain anti-patterns during development.
引用
收藏
页码:3145 / 3158
页数:14
相关论文
共 50 条
  • [21] Starter Projects in Python']Python Programming Classes
    Weigend, Michael
    [J]. DIGITAL TRANSFORMATION OF EDUCATION AND LEARNING - PAST, PRESENT AND FUTURE, OCCE 2021, 2022, 642 : 104 - 115
  • [22] Using GitHub Copilot for Test Generation in Python']Python: An Empirical Study
    El Haji, Khalid
    Brandt, Carolin
    Zaidman, Andy
    [J]. PROCEEDINGS OF THE 2024 IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATION OF SOFTWARE TEST, AST 2024, 2024, : 45 - 55
  • [23] Towards an understanding of memory leak patterns: an empirical study in Python']Python
    Chen, Jie
    Yu, Dongjin
    Hu, Haiyang
    [J]. SOFTWARE QUALITY JOURNAL, 2023, 31 (04) : 1303 - 1330
  • [24] An Empirical Study on the Impact of Python']Python Dynamic Typing on the Project Maintenance
    Xia, Xinmeng
    Yan, Yanyan
    He, Xincheng
    Wu, Di
    Xu, Lei
    Xu, Baowen
    [J]. INTERNATIONAL JOURNAL OF SOFTWARE ENGINEERING AND KNOWLEDGE ENGINEERING, 2022, 32 (05) : 745 - 768
  • [25] An empirical study of the Python']Python/C API on evolution and bug patterns
    Hu, Mingzhe
    Zhang, Yu
    [J]. JOURNAL OF SOFTWARE-EVOLUTION AND PROCESS, 2023, 35 (02)
  • [26] What Are the Dominant Projects in the GitHub Python']Python Ecosystem?
    Ma, Wanwangying
    Chen, Lin
    Zhou, Yuming
    Xu, Baowen
    [J]. PROCEEDINGS 2016 THIRD INTERNATIONAL CONFERENCE ON TRUSTWORTHY SYSTEMS AND THEIR APPLICATIONS (TSA), 2016, : 87 - 95
  • [27] USING PYTHON']PYTHON FOR THE DEVELOPMENT OF ELECTRICAL ENGINEERING PROJECTS
    Milano, Federico
    Zarate Minano, Rafael
    [J]. 2011 4TH INTERNATIONAL CONFERENCE OF EDUCATION, RESEARCH AND INNOVATION (ICERI), 2011, : 5863 - 5872
  • [28] An Empirical Study of Flaky Tests in Python
    Gruber, Martin
    Lukasczyk, Stephan
    Kroiß, Florian
    Fraser, Gordon
    [J]. Lecture Notes in Informatics (LNI), Proceedings - Series of the Gesellschaft fur Informatik (GI), 2022, P-320 : 37 - 38
  • [29] Study of defects in a program code in Python
    I. E. Bronshteyn
    [J]. Programming and Computer Software, 2013, 39 : 279 - 284
  • [30] Rotten green tests in Java']Java, Pharo and Python']Python An empirical study
    Aranega, Vincent
    Delplanque, Julien
    Martinez, Matias
    Black, Andrew P.
    Ducasse, Stephane
    Etien, Anne
    Fuhrman, Christopher
    Polito, Guillermo
    [J]. EMPIRICAL SOFTWARE ENGINEERING, 2021, 26 (06)