Python Typing Survey 2026: AI Tools and the Shifting Checker Landscape

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Python Typing Survey 2026: AI Tools and the Shifting Checker Landscape

The 2026 Python Typing Survey received 1,794 responses. Type hint use changed little across three years, but checker selection changed sharply. Among respondents who reported which checkers they use, half selected more than one, and missing library type information was the most common difficulty. 2026年Python类型检查调查共收到1,794份回复。过去三年中,类型提示的使用率变化不大,但检查工具的选择发生了剧烈变化。在报告了所用检查工具的受访者中,有一半人选择了不止一种,而缺失库类型信息是最常见的困难。

For the third consecutive year, we asked Python developers how they use and experience Python typing: the language features, specifications, and tools used to describe and check types in Python code. We run the survey to learn what is working and what library maintainers, tool builders, documentation authors, and standards contributors should tackle next. 这是我们连续第三年询问Python开发者如何使用和体验Python类型系统:即用于描述和检查Python代码类型的语言特性、规范和工具。我们开展这项调查旨在了解哪些方面行之有效,以及库维护者、工具构建者、文档作者和标准贡献者接下来应重点解决的问题。

Most respondents were experienced Python developers: 76.4% had used Python for at least five years. The clearest change was the shift in checker choice, while missing library type information remained the most common difficulty. 大多数受访者是经验丰富的Python开发者:76.4%的人使用Python至少五年。最明显的变化是检查工具选择的转变,而缺失库类型信息依然是最普遍的困难。

Key Takeaways From the 2026 Python Typing Survey 2026年Python类型检查调查的主要结论

This year’s findings show several recurring opportunities: Broader and more accurate type information would help users of data-science packages: Dynamic frameworks pose a different challenge because current type systems cannot express some runtime behavior. Possible directions include new typing features and checker support tailored to individual libraries and frameworks. 今年的调查结果显示了几个反复出现的机会:更广泛且更准确的类型信息将有助于数据科学包的用户;动态框架带来了不同的挑战,因为当前的类型系统无法表达某些运行时行为。可能的方向包括新的类型特性以及针对特定库和框架定制的检查工具支持。

Tool builders could focus on editor feedback and an initial checker run that requires little configuration: Error messages could link to short explanations and examples. Typing documentation can assume Python experience. Projects using multiple checkers would benefit from clear explanations of intentional differences between them. Better callable syntax remains a practical area for standards work, especially if improvements keep common typing tasks straightforward. 工具构建者可以专注于编辑器反馈和几乎无需配置的初始检查运行:错误消息可以链接到简短的解释和示例。类型文档可以预设读者具备Python经验。使用多种检查工具的项目若能明确解释它们之间的有意差异,将从中受益。更好的可调用对象(callable)语法仍然是标准工作的实用领域,特别是如果改进能保持常见类型任务的简洁性。

AI usage remains an open question: The findings on AI leave an open question about which interactions between AI tools and type checkers help developers. Further empirical study could inform future designs. AI的使用仍是一个悬而未决的问题:关于AI工具与类型检查器之间哪些交互对开发者有帮助,调查结果尚未给出定论。进一步的实证研究可以为未来的设计提供参考。

AI Tools Now Write Types and Respond to Checker Errors AI工具现在可以编写类型并响应检查错误

The share of respondents who selected “Makes AI-generated code more accurate/reliable” rose from 18.5% in 2025 to 38.4% in 2026. AI tools wrote type hints for 42.5% of 1,517 respondents, while 32.6% wrote types to improve AI-generated code. Respondents also used AI to fix or explain type errors. Across all four activities listed for AI tool use in typing, 61.0% of respondents reported they used at least one of these options. 选择“使AI生成的代码更准确/可靠”的受访者比例从2025年的18.5%上升至2026年的38.4%。在1,517名受访者中,42.5%的人使用AI工具编写类型提示,而32.6%的人通过编写类型来改进AI生成的代码。受访者还使用AI来修复或解释类型错误。在列出的四项AI辅助类型编写活动中,61.0%的受访者表示至少使用过其中一项。

Some respondents said their AI coding tool runs the checker and then fixes the errors. Of the 1,517 developers who answered how they run a checker, 24.4%, said an AI coding tool invoked their checker. Among the 370 respondents, 61.6% also used AI to fix checker errors. The rate was 19.3% among everyone else. 一些受访者表示,他们的AI编码工具会运行检查器并自动修复错误。在回答如何运行检查器的1,517名开发者中,24.4%的人表示AI编码工具调用了他们的检查器。在这370名受访者中,61.6%的人还使用AI来修复检查错误,而其他受访者中的这一比例为19.3%。

Some respondents described AI-generated types that are too broad and agents that suppress checker errors: “I fix AI coded type hints because AI often gets lazy and uses object for everything.” “Lazy coding agents that spam #type: ignore comments everywhere.” 一些受访者描述了AI生成的类型过于宽泛,以及代理程序抑制检查错误的情况:“我必须修复AI编写的类型提示,因为AI经常偷懒,对所有东西都使用object。”“懒惰的编码代理到处乱发 #type: ignore 注释。”

When asked how useful types are for better AI-assisted coding, 29.8% of 1,551 respondents chose “I’m not sure.” The uncertainty rate for AI-assisted coding was nearly four times the 7.7% rate for runtime guarantees, the next-highest of the six benefits. We still need empirical evidence about which interactions actually help. The Pyrefly team is already studying how AI coding tools and type checkers work together. At the 2026 Python Typing Summit, the team presented Type Checking in Agentic Workflows. 当被问及类型对于改善AI辅助编码有多大用处时,1,551名受访者中有29.8%选择了“我不确定”。AI辅助编码的不确定性比例几乎是“运行时保证”这一选项(六项益处中排名第二,为7.7%)的四倍。我们仍然需要实证证据来证明哪些交互真正有效。Pyrefly团队已经在研究AI编码工具和类型检查器如何协同工作。在2026年Python类型峰会上,该团队展示了“代理工作流中的类型检查”。

Library Gaps Lead Overall; Occasional Users Struggle With Complexity 库缺失问题居首;偶尔使用的用户难以应对复杂性

Missing type information in third-party libraries was the leading difficulty, selected by 65.1% of 1,486 respondents. Another 44.6% said the type system could not describe everything their code does. Developers can still have a poor experience after a library ships dedicated stubs. 第三方库中缺失类型信息是首要困难,65.1%的受访者选择了此项。另有44.6%的受访者表示类型系统无法描述其代码的所有行为。即使库发布了专门的存根(stubs),开发者的体验仍可能不佳。

Among 156 people who wrote their own answer, 22 described dynamic constructs, decorators, metaprogramming, or framework behavior. Ten described arrays, dataframes, or scientific typing, and at least eight described annotations that were inaccurate, incomplete, or too broad. Respondents repeatedly named Django, SQLAlchemy, Pydantic, NumPy, pandas, and Polars. “Django does so much black magic it’s a wonder a type checker works at all.” — survey respondent 在156名填写自定义答案的受访者中,22人提到了动态构造、装饰器、元编程或框架行为。10人提到了数组、数据框或科学计算类型,至少8人描述了不准确、不完整或过于宽泛的注解。受访者反复提到的库包括Django、SQLAlchemy、Pydantic、NumPy、pandas和Polars。“Django用了太多的黑魔法,类型检查器能起作用简直是个奇迹。”——受访者语。

Library maintainers need annotations that capture how frameworks and data-science libraries behave. The Pyrefly team has been working with Quansight to improve third-party library typing, including contributions to pandas-stubs and NumPy. 库维护者需要能够捕捉框架和数据科学库行为的注解。Pyrefly团队一直与Quansight合作改进第三方库的类型支持,包括对pandas-stubs和NumPy的贡献。

Frequency of use changed which problems stood out. Among developers who used type hints rarely or sometimes, 41.6% found the type system too complex or verbose. The rate was 14.5% among developers who used type hints often or always. Missing library typing affected 36.2% of the lower-frequency group and 70.0% of the higher-frequency group. “I use the straightforward parts and avoid the parts that are difficult to understand.” — survey respondent. 使用频率的不同改变了突出问题的重点。在很少或有时使用类型提示的开发者中,41.6%的人认为类型系统过于复杂或冗长。而在经常或总是使用类型提示的开发者中,这一比例为14.5%。缺失库类型信息影响了36.2%的低频使用群体和70.0%的高频使用群体。“我只使用简单直接的部分,避开那些难以理解的部分。”——受访者语。

Years of typing experience showed a different pattern. Complexity was reported by 18.2% of respondents with zero to two years of typing experience, 16.0% with three to six years, and 21.0% with seven or more. Newer typing users were often regular users and experienced Python developers: Of the 396 respondents with zero to two years of typing experience, 306 (77.3%) used type hints often or always and 345 (87.1%) had used Python for at least three years. 类型使用经验年限呈现出不同的模式。在类型使用经验为0至2年的受访者中,18.2%的人报告了复杂性问题;3至6年经验的比例为16.0%;7年及以上的比例为21.0%。较新的类型用户通常是常规用户和经验丰富的Python开发者:在396名类型使用经验为0至2年的受访者中,306人(77.3%)经常或总是使用类型提示,345人(87.1%)使用Python至少三年。

Guidance for developers who are new to typing should assume Python experience and show how to add types to an existing repository. Occasional users need a useful first check with little configuration and easy-to-understand errors. As we change the type system, we should aim to support more patterns without making common tasks harder. Better Callable syntax is one practical place to start. It was the most selected missing feature, chosen by 45.7% of the 1,486 respondents who answered the quest 针对类型系统新手的指导应预设其具备Python经验,并展示如何向现有代码库添加类型。偶尔使用的用户需要一个几乎无需配置且错误信息易于理解的初始检查。在改进类型系统时,我们的目标应是支持更多模式,同时不增加常见任务的难度。更好的可调用对象语法是一个切实的起点。它是最常被选中的缺失特性,在回答该问题的1,486名受访者中,有45.7%的人选择了它。