It's a small refactoring. Lurking at collections.abc I found a lot of: >>> any(attr in B.__dict__ for B in C.__mro__) also repeated in typing.py of mypy: https://github.com/JukkaL/mypy/blob/master/lib-typing/3.2/typing.py#L117 It seems to be a common operation to check or get an attribute from mro in abc, so I thought it could help to have dedicated functions to enhance readability. (see patch e.g. Hash.__subclasshook__ takes 1 line intead of 7...)
See #25958, which incorporates a similar refactoring in service of making all of the subclasshooks in collections.abc handle None the same way. We definitely do want something public in the abc module like this, rather than the private function in collections.abc that I wrote, especially given the discussion about moving a bunch of the ABCs to other modules.
Honestly I don't think this is worth it. The proposed functions seem to fall firmly in the territory of "not every three useful lines of code are worth a stdlib function".
History
Date
User
Action
Args
2022-04-11 14:58:07
admin
set
github: 66464
2021-10-21 19:20:23
iritkatriel
set
status: open -> closedresolution: rejectedstage: resolved