Type Hints in Python Libraries and Frameworks: An Empirical Analysis of Adoption and Maintenance

📅 2026-09-02
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
研究分析了1000个GitHub仓库中Python库和框架对类型提示的采用、维护情况,通过提取类型注解等方法探讨其使用模式及演变。
📝 Abstract
Context: In Python, type hints allow developers to annotate variables and functions with explicit type information, improving code clarity and reliability. Although type hints are widely available, little is known about how they are adopted and maintained in libraries and frameworks. Objective: We investigate the adoption, usage, maintenance, and rationale of type hints in Python libraries and frameworks. Method: We analyzed 1,000 popular GitHub repositories, identifying libraries and frameworks and extracting their type annotations. We examined annotation coverage, the locations and origins of annotations, their evolution across git histories, and the relationship between developer annotations and types inferred by Pyright. Results: Of the analyzed repositories, 91% of libraries use type hints at least once, although adoption is inconsistent. Among libraries with systematic usage, maintainers prioritize function parameters and return types, with median coverage of 45.8% and 35.9%, respectively, and mainly use built-in types (73.0%). When modified, annotations tend to migrate to more expressive types. Developers annotate members even when Pyright can infer their types, and these annotations often simplify the inferred type. Conclusion: Type hints in Python libraries and frameworks primarily serve as API contracts rather than comprehensive descriptions of implementation details. The findings suggest opportunities for tooling that prioritizes public interfaces, identifies meaningful annotation changes, and supports maintainers in evolving type information.
Problem

Research questions and friction points this paper is trying to address.

type hints
Python libraries
adoption
maintenance
GitHub repositories
Innovation

Methods, ideas, or system contributions that make the work stand out.

Type Hints
Python Libraries
Annotation Coverage
API Contracts
Code Maintenance
🔎 Similar Papers