gh-126705: Make os.PathLike more like a protocol#126706
gh-126705: Make os.PathLike more like a protocol#126706AlexWaygood merged 3 commits intopython:mainfrom
Conversation
johnslavik
left a comment
There was a problem hiding this comment.
On-topic: LGTM
Off-topic:
Makes me wonder why not allow ABC in bases here:
Line 2006 in a6d48e8
It's such a common base class, is there anything mutually exclusive with abstract classes and protocols? This PR proves false.
|
I think the need for the explicit allowlist is that not all ABCs are protocol-like; only ABCs with a |
|
I think I see the confusion: being able to use PathLike as a protocol base only requires adding it to |
it can now be used as a base class in other protocols
it can now be used as a base class in other protocols
This MR makes
os.PathLikemore protocol-like in two ways:class PathLike(metaclass=abc.ABCMeta)instead ofclass PathLike(abc.ABC). This aligns with the other protocol-like ABCs incollections.abc. Actual protocols do have that metaclass but don't have theabc.ABCbase class. Doing this makes it a little smoother for typeshed to define the class asclass PathLike(Protocol)in the stubs.