Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-126705: Make os.PathLike more like a protocol#126706
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 allowABC in bases here:
Line 2006 ina6d48e8
| basein {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 |
Uh oh!
There was an error while loading.Please reload this page.
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!
a83472f intopython:mainUh oh!
There was an error while loading.Please reload this page.
it can now be used as a base class in other protocols
it can now be used as a base class in other protocols
Uh oh!
There was an error while loading.Please reload this page.
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.