What is it about?

This paper presents the first large-scale empirical study on the evolution of type annotations and type errors in Python. The goal of the study was to understand the adoption rate of type annotations and type checkers in the programming language, as well as to identify any patterns or strategies that developers may follow when using them.

Featured Image

Why is it important?

The study was conducted by analyzing over 1 million type annotation changes in 9,655 projects. The results showed that type annotations are becoming increasingly popular and once added, often remain unchanged in projects for a long time. This indicates that once developers start using type annotations, they tend to stick with them. The study also found that projects follow different patterns of type annotation usage. The authors identified three patterns: regular annotation, type sprints, and occasional use. The used pattern was found to correlate with the number of contributors, suggesting that larger projects with more contributors are more likely to follow the regular annotation pattern. In terms of the impact of type annotations on type errors, the study found that adding more type annotations helps find more type errors, with a correlation of 0.704. However, despite this positive relationship, the authors found that many commits (78.3%) are still committed despite containing type errors. This highlights the need for better developer training and automated techniques for adding type annotations, as well as for a better integration of gradual type checking into the development process.

Perspectives

Overall, the results of this study provide valuable insights into the adoption and usage of type annotations and type checkers in Python. The findings can help inform the development of tools and best practices for improving the reliability and maintainability of code written in dynamically typed programming languages.

Luca Di Grazia
Universitat Stuttgart

Read the Original

This page is a summary of: The evolution of type annotations in python: an empirical study, November 2022, ACM (Association for Computing Machinery),
DOI: 10.1145/3540250.3549114.
You can read the full text:

Read

Resources

Contributors

The following have contributed to this page