python / python/cpython

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

Open
#127,677 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs topic-typing
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typing.Protocol documentation linked in the issue and compare its guidance with PEP 544. Review the Protocol examples and explanations for the requested ABCMeta, abstractmethod, and reference coverage. Done means the relevant user-facing details are documented and the PEP reference is framed as historical context.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.