The docs state that "This method should return True, False or NotImplemented" but the example given only returns True | NotImplemented. This makes it hard for the user to understand how to use the method themselves.
In particular it's not clear to the reader:
Why they may want to return NotImplemented instead of False (this is a common pattern used in stdlib ABCs).
That returning False in __subclasshook__ will override the registration of a class due to the issubclass algorithm. [1][2]
JosephSBoyle commentedDec 21, 2022
Documentation
The docs for subclasshook[0] contains the following example:
The docs state that "This method should return True, False or NotImplemented" but the example given only returns
True | NotImplemented
. This makes it hard for the user to understand how to use the method themselves.In particular it's not clear to the reader:
NotImplemented
instead ofFalse
(this is a common pattern used in stdlib ABCs).False
in__subclasshook__
will override the registration of a class due to theissubclass
algorithm. [1][2][0] https://docs.python.org/3.12/library/abc.html#abc.ABCMeta.__subclasshook__
[1] Demonstration of this:
[2] My understanding of the
issubclass
algorithm is described in this comment: #61035 (comment)The text was updated successfully, but these errors were encountered: