Using `types` classes over `collections.abc`'s bases
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 302
- 平均合并
- 23 小时
- 30 天内合并 PR
- 8
描述
Currently collections.abc.Generator/Coroutine/AsyncGenerator etc. have attributes that don't have to exist at runtime. I think it'd be wise to switch recommending to using the types concrete classes where possible over the abstract versions which have a smaller interface because having this weird sort of duplication where the 2 are basically the same is a wrinkle that's bitten me recently. To do this I think a few things need to happen:
- make the classes in
collections.abc.pyiProtocols that should be based on their runtime implementation (they implement custom__subclasshook__) and not the concrete types. (https://github.com/python/typeshed/pull/10816) - make the
typesclasses subscriptable at runtime. (https://github.com/python/cpython/pull/110212) - make type checkers infer things like
def foo(): yieldastypes.GeneratorTypeand not justcollections.abc.Generator.
(as a small aside it might be nice to move the type implementations from typing to collections.abc soon)
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先查看 collections.abc.pyi 中的类,以及相关的 typeshed 和 CPython pull request。然后检查类型检查器如何推断 generator、coroutine 和 async-generator 函数。当抽象类型和具体类型在已识别的所有更改中都具有所提议的运行时行为和推断行为时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100