SEJul 10

Automating Just-In-Time Python Type Annotation Updating

arXiv:2607.090544.2h-index: 3
Predicted impact top 82% in SE · last 90 daysOriginality Incremental advance
AI Analysis

For Python developers, this reduces outdated type annotations that cause bugs and comprehension issues, offering a practical solution for maintaining annotation consistency.

TypeUp automates updating Python type annotations alongside code changes, outperforming the state-of-the-art TypeGen by 41.9% and achieving 80% developer acceptance in real-world projects.

Type annotations are more and more popular in Python projects to avoid type errors caused by Python's dynamic typing feature. However, when developers change source code, these type annotations are often neglected or overlooked, resulting in outdated and inconsistent type annotations. Such obsolete type annotations can hinder program comprehension, mislead developers, and even introduce bugs in the future. Therefore, it is necessary to avoid and correct these inconsistent type annotations from the very beginning. In this work, we argue that obsolete type annotations can be reduced and even avoided by automatically updating type annotations alongside code changes. We refer to this task as "Just-In-Time (JIT) type annotation updating". To solve this task, we propose a novel LLM-based approach named TypeUp (Type Annotation Updator) to automate this task. TypeUp can automatically generate new type annotations based on the old type annotations and corresponding code changes. Specifically, TypeUp guides LLM to perform type annotation updates by eliciting its knowledge and logical reasoning power and learning from similar code changes. The evaluation results show that TypeUp outperforms state-of-the-art type infer approach (i.e., TypeGen) by 41.9% on our task. Moreover, we conducted an in-the-wild evaluation with real-world software projects, 20 out of 25 type annotation updates generated by our approach have already been confirmed by developers, showing our approach's practical value in real-world environments.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes