python / python/cpython

`Protocol` should be documented as using `ABCMeta` as metaclass

未關閉
#127,677 1 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

docs topic-typing
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Documentation

Came up in #127648.

Currently the documentation for typing.Protocol doesn't mention that Protocol has ABCMeta in its metaclasses (indirectly via _ProtocolMeta) and that its methods can (should?) be marked with @abstractmethod. In fact, neither the string "ABCMeta" nor "abstractmethod" appear in the documentation for the typing module.

I also suggest to add @abstractmethod to the examples using a Protocol as that is probably a best practice.

Finally, the documentation for Protocol suggests to see PEP 544 for more details. I don't think this is particularly helpful. All information relevant for users should be in the main documentation. PEP 544 should only be suggested as a historical document. (And I don't suggest to directly link to the typing spec, either, although a general link at the top of the page would be useful.)

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中連結的 typing.Protocol 文件開始,並將其中的指引與 PEP 544 進行比較。檢查 Protocol 的範例和說明,確認對 ABCMeta、abstractmethod 以及參照的要求涵蓋情況。相關的面向使用者細節已完成文件記錄,且對 PEP 的參照被定位為歷史背景,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
documentation
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。