-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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-126705: Make os.PathLike more like a protocol #126706
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On-topic: LGTM
Off-topic:
Makes me wonder why not allow ABC
in bases here:
Line 2006 in a6d48e8
base in {object, Generic} |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
This MR makes
os.PathLike
more 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.ABC
base class. Doing this makes it a little smoother for typeshed to define the class asclass PathLike(Protocol)
in the stubs.