Lune

ICSE2026Top-tier venue

Automating Just-In-Time Python Type Annotation Updating

Zhipeng Xue, Zhipeng Gao, Xing Hu, Jingyuan Chen, Xin Xia, Shanping Li

Abstract

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 the state-of-the-art type inference approach (i.e., TypeGen) by 41.9% on our task. Moreover, we conducted a practical application 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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

Questions to start from

Lune can draw on

the full paper · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Automated Program Repair in the Era of Large Pre-trained Language Models cites CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
Builds onCited byLeft to right by year; the more cited, the higher.

Builds on19

  1. CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 citations
  2. Automated Program Repair in the Era of Large Pre-trained Language ModelsChunqiu Steven Xia, Yuxiang Wei, Lingming ZhangICSE 2023 · 321 citations
  3. LambdaNet: Probabilistic Type Inference using Graph Neural NetworksJiayi Wei, Maruth Goyal, Greg Durrett, Isil DilligICLR 2020 · 119 citations
  4. TypeWriter: neural type prediction with search-based validationMichael Pradel, Georgios Gousios, Jason Liu, Satish ChandraFSE 2020 · 102 citations
  5. Typilus: neural type hintsMiltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng GaoPLDI 2020 · 92 citations

Related papers

  1. Static Type Recommendation for PythonKe Sun, Yifan Zhao, Dan Hao, Lu ZhangASE 2022 · 6 citations
  2. Co-evolution of Types and Dependencies: Towards Repository-Level Type Inference for Python CodeShuo Sun, Shixin Zhang, Jiwei Yan, Jun Yan et al.FSE 2026
  3. The evolution of type annotations in python: an empirical studyLuca Di Grazia, Michael PradelFSE 2022 · 29 citations
  4. TypeCare: Boosting Python Type Inference Models via Context-Aware Re-Ranking and AugmentationWonseok Oh, Hakjoo OhICSE 2026
  5. PyTER: effective program repair for Python type errorsWonseok Oh, Hakjoo OhFSE 2022 · 22 citations
Dusk over the sea between two cliffs drawn in fine vertical lines