PyTy: Repairing Static Type Errors in Python
Not on the map. Why?
Abstract (arXiv)
Gradual typing enables developers to annotate types of their own choosing, offering a flexible middle ground between no type annotations and a fully statically typed language. As more and more code bases get type-annotated, static type checkers detect an increasingly large number of type errors. Unfortunately, fixing these errors requires manual effort, hampering the adoption of gradual typing in practice. This paper presents PyTy, an automated program repair approach targeted at statically detectable type errors in Python. The problem of repairing type errors deserves specific attention because it exposes particular repair patterns, offers a warning message with hints about where and how to apply a fix, and because gradual type checking serves as an automatic way to validate fixes. We addresses this problem through three contributions: (i) an empirical study that investigates how developers fix Python type errors, showing a diverse set of fixing strategies with some recurring patterns; (ii) an approach to automatically extract type error fixes, which enables us to create a dataset of 2,766 error-fix pairs from 176 GitHub repositories, named PyTyDefects; (iii) the first learning-based repair technique for fixing type errors in Python. Motivated by the relative data scarcity of the problem, the neural model at the core of PyTy is trained via cross-lingual transfer learning. Our evaluation shows that PyTy offers fixes for ten frequent categories of type errors, successfully addressing 85.4% of 281 real-world errors. This effectiveness outperforms state-of-the-art large language models asked to repair type errors (by 2.1x) and complements a previous technique aimed at type errors that manifest at runtime. Finally, 20 out of 30 pull requests with PyTy-suggested fixes have been merged by developers, showing the usefulness of PyTy in practice.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). First posted on arXiv 12 Jan 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 4; 2025: 4; 2026: 2.
10 papers.
- 2024AutoCodeRover: Autonomous Program Improvementcited by 272
- 2024RepairAgent: An Autonomous, LLM-Based Agent for Program Repaircited by 225
- 2025Beyond Final Code: A Process-Oriented Error Analysis of Software Development Agents in Real-World GitHub Scenarioscited by 14
- 2025Reflections on the Reproducibility of Commercial LLM Performance in Empirical Software Engineering Studiescited by 12
- 2025Combining Large Language Models with Static Analyzers for Code Review Generationcited by 6
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
- 2024REDO: Execution-Free Runtime Error Detection for COding Agentscited by 2
- 2026AgenticTyper: Automated Typing of Legacy Software Projects Using Agentic AIcited by 2
- 2024PatUntrack: Automated Generating Patch Examples for Issue Reports without Tracked Insecure Codecited by 1
- 2026The Alignment Problem in Constrained Code Generationcited by 1
- 2026The Alignment Problem in Constrained Code Generation19 Jun 2026
- 2026AgenticTyper: Automated Typing of Legacy Software Projects Using Agentic AI21 Feb 2026
- 2025Reflections on the Reproducibility of Commercial LLM Performance in Empirical Software Engineering Studies29 Oct 2025
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMs16 Apr 2025
- 2025Beyond Final Code: A Process-Oriented Error Analysis of Software Development Agents in Real-World GitHub Scenarios16 Mar 2025
- 2025Combining Large Language Models with Static Analyzers for Code Review Generation10 Feb 2025
- 2024REDO: Execution-Free Runtime Error Detection for COding Agents10 Oct 2024
- 2024PatUntrack: Automated Generating Patch Examples for Issue Reports without Tracked Insecure Code16 Aug 2024
- 2024AutoCodeRover: Autonomous Program Improvement8 Apr 2024
- 2024RepairAgent: An Autonomous, LLM-Based Agent for Program Repair25 Mar 2024