-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Fix some type issues with trio.Path
#2815
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2815 +/- ##
=======================================
Coverage 99.13% 99.13%
=======================================
Files 115 115
Lines 17230 17242 +12
Branches 3084 3085 +1
=======================================
+ Hits 17081 17093 +12
Misses 104 104
Partials 45 45
|
Also fixing an interesting docs build error caused by Python 3.12 releasing. |
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.
I don't see anything glaringly obvious but this is a big diff for what feels like pretty minor changes so I also glossed over a ton...
"suffix", | ||
"suffixes", | ||
} | ||
assert len(extra) == before - 10 |
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.
Codecov warnings here and above seem out of place. Is that just some codecov flakiness?
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.
It seems fine on the Codecov site, so it's probably just GitHub integration not working perfectly.
@@ -0,0 +1,118 @@ | |||
"""Path wrapping is quite complex, ensure all methods are understood as wrapped correctly.""" |
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.
I wish there was a nicer way to check we conform to typeshed's type hints and I think there might be other places where that would benefit us. But I'm not sure really how and it's probably worth punting that to another PR if we ever figure it out.
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.
It's tricky, since we're not actually entirely conforming - we switch to async of course, and automatically replace pathlib.Path
→ trio.Path
. Perhaps the best way might be to do things like code generation to create the tests?
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.
Let's just defer on this. Let's merge this PR!
I think you should take this opportunity to enable type-checking on |
The former returned py.path.local objects, pathlib is the replacement.
After testing my own code against the new hints, I noticed that I messed up the path stubs a little. This fixes them in a more principled way, by going through the definitions in the same order that the typeshed stubs do for
pathlib.Path
. Things inherited fromPurePath
should be sync, whilePath
methods are async (some were mixed up). To ensure all the definitions are correct, I wrote a type-test which just uses every method to check it's doing the right thing.