Add decorator to mark class as concrete / instantiable
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
首先結合現有的 @final 裝飾器以及針對 Pyright 和 Ty 所描述的抽象方法行為來審查該提案。定義具體類別裝飾器預期的型別檢查語意,並確認對於包含抽象方法的類別,錯誤會在類別定義時回報,同時不會將該類別設為 final。
由索引模型根據 Issue 內容生成。
描述
We have the @final decorator to mark a class as final, so that it cannot be subclassed. Typecheckers can then cue off of this to raise an error when there are unimplemented abstract methods (e.g. the Ty abstract-method-in-final-class rule).
Similarly, Pyright and Ty can flag errors when other code instantiates a class that has abstract methods.
However, I would find it very useful to be able to mark a class as concrete: it isn't final (someone might subclass it), but it is intended to be instantiable. This would allow the type checker to raise abstract method errors at the point of class definition, rather than elsewhere in the code where the class is instantiated. For classes that are instantiated directly, the error location isn't a huge problem; for classes that are primarily instantiated indirectly, however, it there is no guarantee that the code will include a direct instantiation of the class to raise an error.
- 主要語言
- Python
- 星號
- 1.8k
- 分支
- 302
- 平均合併
- 4 小時 16 分鐘
- 30 天內合併 PR
- 7
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/typing 的其他 Issue
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 72/100
python/typing#2356 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
Update reference/generics.html with PEP695 type parameter syntax可能已有人在做 @BHUVANSH855 於 180 天前認領。 未關閉topic: documentation
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
topic: documentation
難度 2/5 1-3 小時 新手友好度 65/100
python/typing#2150 · 2 則留言 · 2 個 reaction ·
維護者通常 1 天內回覆
-
topic: conformance tests topic: typing spec
難度 3/5 1-2 天 新手友好度 72/100
維護者通常 1 天內回覆
相似的 Issue
-
camlight produces degenerate target camera and light frames可能已有人在做 @kavyabhand 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
google-deepmind/mujoco_warp#1743 ·
維護者通常 1 天內回覆
-
Package: Update Request
難度 2/5 1-3 小時 新手友好度 72/100
getsolus/packages#10933 · 1 則留言 ·
維護者通常 1 天內回覆
-
[work-item] adam-adae-serious-events: pin missing-AESER filter semantics可能已有人在做 @muse-yamaa-bot 今天認領。 未關閉work-item
難度 1/5 1-3 小時 新手友好度 90/100
維護者通常 1 天內回覆
-
[Bug]: Non-vision image fallback calls vision_analyze with an empty source for oversized inline images and tells the model the image is corrupt可能已有人在做 @liuhao1024 今天認領。 未關閉comp/agent P2 tool/vision type/bug
難度 2/5 1-3 小時 新手友好度 88/100
NousResearch/hermes-agent#132605 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
pymc-labs/pymc-marketing#3102 · 1 則留言 ·
維護者通常 1 天內回覆