-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Type hints for pathlib.types
#130798
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
Comments
Since this is the case, I don't think we'll need to bother about import time then. Are you planning to have more protocol-like classes, namely something that evolves like |
It's currently a mix of protocols ( |
My inspiration for the name was |
Err, ok, let's keep it ".types" instead. That way, we can reserve ".abc" for future usage and usage that can be imported by Also, now that I think about, |
FWIW, I don't think |
I was all okay with the proposed plan (which also seems to be already implemented?) until I saw that you were planning to release some part of the stdlib as a PyPI package. Can you explain why you want that? |
Two reasons:
Does that make sense? I'm happy to change tack if you'd prefer. |
Thanks, that all makes sense to me. |
My understanding (Discourse ref) is that we are avoiding adding type hints to the standard library, as they are both more easily changeable in and overriden by typeshed. From that Discourse thread, "Given that typeshed is supposed to override the stdlib, having the same annotations in the stdlib itself wouldn’t gain us anything, and having different annotations might be confusing to users." Indeed, we have recently removed some annotations from the stdlib where typeshed does a better job. Perhaps we should hold off on adding type annotations to A |
Huh, I thought we only avoided them for performance reasons. I don't see the point in splitting them across repositories otherwise, as it makes it too easy for things to go out-of-sync. |
I'll follow up in discourse |
Yes, and that's what I said for others. However, Barney said that |
I've replied in discourse (sorry for the delay). I'd personally suggest that the annotations are contributed to |
Since Or are you suggesting to make both available under the pathlib namesspace, therefore requiring to work around the typing import? |
Feature or enhancement
The
pathlib.types
module is new in 3.14, and contains a single public class:pathlib.types.PathInfo
.This module also contains a few private classes:
_PathParser
,_JoinablePath
,_ReadablePath
and_WritablePath
.As the
pathlib.types
module is not imported bypathlib
, I think we're free to add proper type annotations to the entire module, including the private classes. I think this will help clarify the interface.I'd like these hints to be compatible with the oldest version of Python still receiving security updates (3.9 at time of writing) because I'm hoping to provide a PyPI package from this module.
Linked PRs
The text was updated successfully, but these errors were encountered: