Avoid eagerly evaluating annotations
未关闭
还没有人认领这个 Issue。
3.14
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
There are various places in the stdlib where we access the .__annotations__ attribute. Under PEP-649 / PEP-749, this now forces evaluation of lazy annotations. We should avoid evaluating annotations where it is not necessary.
For example, currently typing.Protocol evaluates its annotations at protocol creation time.
Linked PRs
- gh-132494
- gh-132534
- gh-132596
- gh-133411
- gh-133415
- gh-133796
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查相关的 PR,以及 stdlib 中访问 .__annotations__ 的位置,并以 typing.Protocol 作为具体示例。使用 PEP-649 和 PEP-749 了解惰性 annotation 的行为;完成的标准是避免不必要的 annotation 求值,尤其是在创建 protocol 期间。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 重构
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100