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 principled, statistically guided adaptive sampling, RightTyper balances runtime overhead with the need to observe sufficient execution behavior to infer high-quality type annotations. We evaluate RightTyper against static, dynamic, and AI-based systems on both synthetic benchmarks and real-world code, and find that it consistently achieves higher semantic similarity to ground-truth and developer-written annotations, respectively, while incurring only approximately 27% runtime overhead.


翻译:暂无翻译

0
下载
关闭预览

相关内容

掌握使用Python的大型语言模型
专知会员服务
63+阅读 · 2024年5月22日
【2020新书】高级Python编程,620页pdf
专知会员服务
240+阅读 · 2020年7月31日
【干货书】流畅Python,766页pdf,中英文版
专知会员服务
228+阅读 · 2020年3月22日
【新书】Python编程基础,669页pdf
专知会员服务
197+阅读 · 2019年10月10日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
百闻不如一码!手把手教你用Python搭一个Transformer
大数据文摘
18+阅读 · 2019年4月22日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
使用Python进行图像增强
AI研习社
17+阅读 · 2018年9月30日
在Python中使用SpaCy进行文本分类
专知
24+阅读 · 2018年5月8日
荐书丨Python数据分析从入门到精通
程序人生
18+阅读 · 2018年3月31日
Python 3 尴尬了这么久,终于有救了
AI100
13+阅读 · 2017年11月18日
各种相似性度量及Python实现
机器学习算法与Python学习
11+阅读 · 2017年7月6日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
11+阅读 · 2018年10月17日
VIP会员
相关VIP内容
掌握使用Python的大型语言模型
专知会员服务
63+阅读 · 2024年5月22日
【2020新书】高级Python编程,620页pdf
专知会员服务
240+阅读 · 2020年7月31日
【干货书】流畅Python,766页pdf,中英文版
专知会员服务
228+阅读 · 2020年3月22日
【新书】Python编程基础,669页pdf
专知会员服务
197+阅读 · 2019年10月10日
相关资讯
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
百闻不如一码!手把手教你用Python搭一个Transformer
大数据文摘
18+阅读 · 2019年4月22日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
使用Python进行图像增强
AI研习社
17+阅读 · 2018年9月30日
在Python中使用SpaCy进行文本分类
专知
24+阅读 · 2018年5月8日
荐书丨Python数据分析从入门到精通
程序人生
18+阅读 · 2018年3月31日
Python 3 尴尬了这么久,终于有救了
AI100
13+阅读 · 2017年11月18日
各种相似性度量及Python实现
机器学习算法与Python学习
11+阅读 · 2017年7月6日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员