Getting Python Types Right with RightTyper
Juan Altmayer Pizzorno, Emery D. Berger

TL;DR
RightTyper is a hybrid Python type inference system that combines runtime observations with static analysis to produce accurate, high-quality type annotations with minimal overhead, improving upon prior methods.
Contribution
It introduces a novel hybrid approach grounded in actual program execution, integrating static analysis and adaptive sampling for precise type inference.
Findings
Achieves higher semantic similarity to ground-truth annotations.
Incur approximately 27% runtime overhead.
Outperforms static, dynamic, and AI-based systems on benchmarks.
Abstract
Python type annotations enable static type checking, but most code remains untyped because manual annotation is time-consuming and tedious. Past approaches to automatic type inference fall short: static methods struggle with dynamic features and infer overly broad types; AI-based methods are unsound and miss rare types; and dynamic methods impose extreme overheads (up to 270x), lack important language support such as inferring variable types, or produce annotations that cause runtime errors. This paper presents RightTyper, a novel hybrid approach for Python that produces accurate and precise type annotations grounded in actual program behavior. RightTyper grounds inference in types observed during actual program execution and combines these observations with static analysis and name resolution to produce substantially higher-quality type annotations than prior approaches. Through…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsComputational Physics and Python Applications · Scientific Computing and Data Management
