Visitar URL original
gh-100407: Improve __subclasshook__ docs by JosephSBoyle · Pull Request #100503 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221231124532/https://github.com/python/cpython/pull/100503
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-100407: Improve __subclasshook__ docs #100503

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

JosephSBoyle
Copy link
Contributor

@JosephSBoyle JosephSBoyle commented Dec 24, 2022 •

  1. Provides a more concise example of __subclasshook__ using list as opposed to a custom Foo class.
  2. Removes .register from the example; IMO it obscured the purpose of the example unclear.
  3. Explains the reason for the important if cls is <ABCType> pattern (used in most stdlib subclasshooks).

image


::

>>> MyIterable in list.__bases__ # Does `list` inherit from `MyIterable`?
Copy link
Member

@sobolevn sobolevn Dec 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you version has completely change the meaning of this example. As far as I understand, it is used to show both __subclasshook__ and .register

In your PR the second part is gone.

Copy link
Contributor Author

@JosephSBoyle JosephSBoyle Dec 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, the meaning is changed in this PR. I don't think we need to keep .register in the subclasshook example. For one it has its own full example right above[1] in the docs.

This change makes the subclasshook docs more specific and removes the stuff about old style iteration etc. that I would argue detract from the existing docs.

1.https://docs.python.org/3.12/library/abc.html#abc.ABCMeta.register

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants