Type Hints in Python Libraries and Frameworks: An Empirical Analysis of Adoption and Maintenance
- URL: http://arxiv.org/abs/2609.02782v1
- Date: Wed, 02 Sep 2026 16:15:09 GMT
- Title: Type Hints in Python Libraries and Frameworks: An Empirical Analysis of Adoption and Maintenance
- Abstract summary: We investigate the adoption, usage, maintenance, and rationale of type hints in Python libraries and frameworks.<n>Of the analyzed repositories, 91% of libraries use type hints at least once, although adoption is inconsistent.<n>When modified, annotations tend to migrate to more expressive types.
- Score: 0.29332247106953097
- License: http://creativecommons.org/licenses/by/4.0/
- 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.
Related papers
- Typify: A Lightweight Usage-driven Static Analyzer for Precise Python Type Inference [7.733270505483109]
Python's dynamic type system poses substantial challenges for static analysis.<n>We introduce Typify, a usage-driven static analysis engine.<n>Typify infers precise and contextually relevant type information without relying on statistical learning.
arXiv Detail & Related papers (2026-04-06T18:13:34Z) - Do Developers Read Type Information? An Eye-Tracking Study on TypeScript [4.249448869949738]
Statically-annotated types have been shown to aid developers in a number of programming tasks.<n>It is hypothesized that this is because developers use type annotations as in-code documentation.
arXiv Detail & Related papers (2026-02-04T18:12:59Z) - RightTyper: Effective and Efficient Type Annotation for Python [0.7673339435080445]
RightTyper generates precise type annotations based on actual program behavior.<n>RightTyper is fast and space-efficient, imposing just 30% performance overhead on average.
arXiv Detail & Related papers (2025-07-21T20:37:35Z) - How Do Developers Use Type Inference: An Exploratory Study in Kotlin [3.382017614888546]
Kotlin is the default language for Android development, one of the largest software marketplaces.
We conduct a large-scale empirical study using Boa, a tool for mining software repositories.
Our findings reveal that type inference is frequently employed for local variables and variables with method calls declared outside the file.
arXiv Detail & Related papers (2024-10-30T18:07:21Z) - Generative Type Inference for Python [62.01560866916557]
This paper introduces TypeGen, a few-shot generative type inference approach that incorporates static domain knowledge from static analysis.
TypeGen creates chain-of-thought (COT) prompts by translating the type inference steps of static analysis into prompts based on the type dependency graphs (TDGs)
Experiments show that TypeGen outperforms the best baseline Type4Py by 10.0% for argument type prediction and 22.5% in return value type prediction in terms of top-1 Exact Match.
arXiv Detail & Related papers (2023-07-18T11:40:31Z) - TypeT5: Seq2seq Type Inference using Static Analysis [51.153089609654174]
We present a new type inference method that treats type prediction as a code infilling task.
Our method uses static analysis to construct dynamic contexts for each code element whose type signature is to be predicted by the model.
We also propose an iterative decoding scheme that incorporates previous type predictions in the model's input context.
arXiv Detail & Related papers (2023-03-16T23:48:00Z) - Selective Annotation Makes Language Models Better Few-Shot Learners [97.07544941620367]
Large language models can perform in-context learning, where they learn a new task from a few task demonstrations.
This work examines the implications of in-context learning for the creation of datasets for new natural language tasks.
We propose an unsupervised, graph-based selective annotation method, voke-k, to select diverse, representative examples to annotate.
arXiv Detail & Related papers (2022-09-05T14:01:15Z) - Annotation Error Detection: Analyzing the Past and Present for a More
Coherent Future [63.99570204416711]
We reimplement 18 methods for detecting potential annotation errors and evaluate them on 9 English datasets.
We define a uniform evaluation setup including a new formalization of the annotation error detection task.
We release our datasets and implementations in an easy-to-use and open source software package.
arXiv Detail & Related papers (2022-06-05T22:31:45Z) - Type4Py: Deep Similarity Learning-Based Type Inference for Python [9.956021565144662]
We present Type4Py, a deep similarity learning-based type inference model for Python.
We design a hierarchical neural network model that learns to discriminate between types of the same kind and dissimilar types in a high-dimensional space.
Considering the Top-1 prediction, Type4Py obtains 19.33% and 13.49% higher precision than Typilus and TypeWriter, respectively.
arXiv Detail & Related papers (2021-01-12T13:32:53Z) - pyBART: Evidence-based Syntactic Transformations for IE [52.93947844555369]
We present pyBART, an easy-to-use open-source Python library for converting English UD trees to Enhanced UD graphs or to our representation.
When evaluated in a pattern-based relation extraction scenario, our representation results in higher extraction scores than Enhanced UD, while requiring fewer patterns.
arXiv Detail & Related papers (2020-05-04T07:38:34Z) - LambdaNet: Probabilistic Type Inference using Graph Neural Networks [46.66093127573704]
This paper proposes a probabilistic type inference scheme for TypeScript based on a graph neural network.
Our approach can predict both standard types, like number or string, as well as user-defined types that have not been encountered during training.
arXiv Detail & Related papers (2020-04-29T17:48:40Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.