Lune

OOPSLA2024顶会

QuAC: Quick Attribute-Centric Type Inference for Python

Jifeng Wu, Caroline Lemieux

摘要

Python's dynamic typing facilitates rapid prototyping and underlies its popularity in many domains. However, dynamic typing reduces the power of many static checking and bug-finding tools. Python type annotations can make these tools more useful. Type inference tools aim to reduce developers' burden of adding them. However, existing type inference tools struggle to support dynamic features, infer correct types (especially container type parameters and non-builtin types), and run in reasonable time. Inspired by Python's duck typing, where the attributes accessed on Python expressions characterize their implicit interfaces, we propose QuAC (Quick Attribute-Centric Type Inference for Python). At its core, QuAC collects attribute sets for Python expressions and leverages information retrieval techniques to predict classes from these attribute sets. It also recursively predicts container type parameters. We evaluate QuAC's performance on popular Python projects. Compared to state-of-the-art non-LLM baselines, QuAC predicts types with high accuracy complementary to those predicted by the baselines while not sacrificing coverage. It also demonstrates clear advantages in predicting container type parameters and non-builtin types and reduces run times. Furthermore, QuAC is nearly two orders of magnitude faster than an LLM-based method while covering nearly half of its errorless non-trivial type predictions. It is also significantly more consistent at predicting container type parameters and non-builtin types than the LLM-based method, regardless of whether the project has ground-truth type annotations.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 3 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Repairing Leaks in Resource Wrappers 引用了 TypeWriter: neural type prediction with search-based validation
  • Co-evolution of Types and Dependencies: Towards Repository-Level Type Inference for Python Code 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
  • Co-evolution of Types and Dependencies: Towards Repository-Level Type Inference for Python Code 引用了 LambdaNet: Probabilistic Type Inference using Graph Neural Networks
  • Co-evolution of Types and Dependencies: Towards Repository-Level Type Inference for Python Code 引用了 TypeWriter: neural type prediction with search-based validation
  • Type4Py: Practical Deep Similarity Learning-Based Type Inference for Python 引用了 Typilus: neural type hints
  • Type4Py: Practical Deep Similarity Learning-Based Type Inference for Python 引用了 LambdaNet: Probabilistic Type Inference using Graph Neural Networks
  • Type4Py: Practical Deep Similarity Learning-Based Type Inference for Python 引用了 TypeWriter: neural type prediction with search-based validation
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper3

  1. Repairing Leaks in Resource WrappersSanjay Malakar, Michael D. Ernst, Martin Kellogg, Manu SridharanASE 2025
  2. Co-evolution of Types and Dependencies: Towards Repository-Level Type Inference for Python CodeShuo Sun, Shixin Zhang, Jiwei Yan, Jun Yan 等FSE 2026
  3. SnakeCharmer: Automatic Fuzzing Harness Generation for Pure and Hybrid Python LibrariesGabriel Sherman, Stefan NagyFSE 2026

它引用的 Paper11

  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 次引用
  2. LambdaNet: Probabilistic Type Inference using Graph Neural NetworksJiayi Wei, Maruth Goyal, Greg Durrett, Isil DilligICLR 2020 · 119 次引用
  3. TypeWriter: neural type prediction with search-based validationMichael Pradel, Georgios Gousios, Jason Liu, Satish ChandraFSE 2020 · 102 次引用
  4. Typilus: neural type hintsMiltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng GaoPLDI 2020 · 92 次引用
  5. Type4Py: Practical Deep Similarity Learning-Based Type Inference for PythonAmir M. Mir, Evaldas Latoskinas, Sebastian Proksch, Georgios GousiosICSE 2022 · 59 次引用

相关 Paper

  1. DLInfer: Deep Learning with Static Slicing for Python Type InferenceYanyan Yan, Yang Feng, Hongcheng Fan, Baowen XuICSE 2023 · 9 次引用
  2. Automating Just-In-Time Python Type Annotation UpdatingZhipeng Xue, Zhipeng Gao, Xing Hu, Jingyuan Chen 等ICSE 2026
  3. Static Type Recommendation for PythonKe Sun, Yifan Zhao, Dan Hao, Lu ZhangASE 2022 · 6 次引用
  4. PyAnalyzer: An Effective and Practical Approach for Dependency Extraction from Python CodeWuxia Jin, Shuo Xu, Dawei Chen, Jiajun He 等ICSE 2024 · 4 次引用
  5. TypePro: Boosting LLM-Based Type Inference via Inter-Procedural SlicingTeyu Lin, Minghao Fan, Huaxun Huang, Zhirong Shen 等FSE 2026
黄昏的海面,两侧是细线勾勒的悬崖