Using `types` classes over `collections.abc`'s bases
還沒有人認領這個 Issue。
評估
研究方向
首先檢視 collections.abc.pyi 中的類別,以及相關的 typeshed 和 CPython pull request。接著檢查型別檢查器如何推論 generator、coroutine 和 async-generator 函式。當抽象型別和具體型別在已識別的所有變更中都具備所提議的執行期行為和推論行為時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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)
- 主要語言
- Python
- 星號
- 1.8k
- 分支
- 302
- 平均合併
- 4 小時 38 分鐘
- 30 天內合併 PR
- 6
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/typing 的其他 Issue
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 72/100
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 75/100
-
Update reference/generics.html with PEP695 type parameter syntax可能已有人在做 @BHUVANSH855 於 182 天前認領。 未關閉topic: documentation
難度 2/5 1-3 小時 新手友好度 76/100
-
topic: documentation
難度 2/5 1-3 小時 新手友好度 65/100
-
Finals and Literals: Spec contradiction可能已有人在做 @srittau 於 35 天前認領。 未關閉topic: conformance tests topic: typing spec
難度 3/5 1-2 天 新手友好度 72/100
相似的 Issue
-
needs-human needs-triage
難度 2/5 1-3 小時 新手友好度 76/100
gke-labs/kube-agents#2400 · 1 則留言 ·
維護者通常 1 天內回覆
-
Device Details tables: FS/SF columns contradict each other (nfet_01v8 Vt row, pfet_01v8 Idsat row)未關閉
難度 2/5 1-3 小時 新手友好度 75/100
google/skywater-pdk#450 ·
-
Drained trajectory arrays are overwritten when the sequence buffer is reused可能已有人在做 @sylvesterkaczmarek 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
google-deepmind/bsuite#56 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
LearningCircuit/local-deep-research#7206 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
chingu-voyages/V62-tier3-team-33#285 ·
維護者通常 1 天內回覆