-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
Add stubs for wrapped methods to trio.Path, add tests for mypy seeing exported symbols, and test for seeing class members #2631
Conversation
adf17df
to
c5b52e4
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2631 +/- ##
==========================================
- Coverage 92.43% 90.84% -1.59%
==========================================
Files 118 118
Lines 16352 16387 +35
Branches 2945 1309 -1636
==========================================
- Hits 15115 14887 -228
- Misses 1124 1358 +234
- Partials 113 142 +29
|
c5b52e4
to
8b6c935
Compare
ab12518
to
be5d3c2
Compare
be5d3c2
to
f3f43d5
Compare
Actually, does trio want a dependency on |
ah yes, good catch |
9f19367
to
1e0da49
Compare
I should maybe spin up a virtual machine at some point so I can test windows stuff better lol |
Huh, looks like pypy has different dunders? I'm guessing they can just be ignored. 'trio.EndOfChannel': {'extra': {'__basicsize__',
'__dictoffset__',
'__itemsize__',
'__sizeof__',
'__weakrefoffset__'},
'missing': {'__unicode__'}}, Windows ones are failing due to path having a colon in |
Yeah those aren't relevant. |
6f3fd88
to
b1e32a8
Compare
Truly incredible. Now we have the worst of both worlds: you have to type out all the wrapper declarations manually and you're testing that you even wrote out the wrapper declarations - and if we ever want to have real asynchronous file I/O all of this has to go anyway. |
I think it's worth the effort to provide better autocomplete! (Sorry if I'm misinterpreting your tone!) The test is just a continuation of what we already test -- just that we are checking that class members match and not just module members. |
I could've implemented the class member check as making the export test more thorough, but was easier to just write a new one than modifying the old one to also do class members. So yes the tests are very much what's currently done already, except with one more tool and testing the public class methods that weren't.
And it's not like I came up with this for nothing - I ran And I have absolutely no problem with all of this getting tossed out when systems are improved! |
These last errors are confusing me (and then there's other problems currently untested that'll need adressing), but I think it boils down to |
b1e32a8
to
bcb0b96
Compare
Okay since getting the stubs correct for the path methods wasn't trivial, I'll postpone that to a different PR so this one can get merged. |
bcb0b96
to
58c5649
Compare
would somebody mind reviewing this? It's ready for merge unless there's any more comments. |
I can check this out in a bit, also the new 3.12 dev errors are concerning (they're not cause you) and we gotta fix those! |
Sorry, haven't gotten to this! Eventually I will, don't worry. |
(just updating this branch based on master as that (should) fix the macos pypy-3.8-nightly cancellation and the formatting check) |
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 was telling myself not to nitpick too much but... Oops. If something feels like a nitpick, feel free to ignore it! (or if it's missing something too obvious, I guess)
write_bytes: Any | ||
write_text: Any | ||
|
||
if sys.platform != "win32": |
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 would be nice to be able to auto-generate this (read from relevant file in https://github.com/python/typeshed and change the types... like just stick an async
in the right places and call it a day). I suppose that's all part of "how will we do this" that is the followup, so ignore this :^)
readlink: Any | ||
if sys.version_info >= (3, 10): | ||
hardlink_to: Any | ||
|
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.
This line isn't the one I wanted to comment on, but I can't comment on it cause it's out of the diff github shows :(
Namely, the line that is os.PathLike.register(Path)
. Presumably we could subclass os.PathLike
and that would help some typing stuff? I don't know though.
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.
Definitely, register
isn't going to be fully supported everywhere. It'd also be better to inherit to indicate that we provide string paths, not bytes. A little tricky though since it's only as of 3.9 that you could subscript PathLike
:
if TYPE_CHECKING:
_StrPathLike = os.PathLike[str]
else:
_StrPathLike = os.PathLike
...
class Path(_StrPathLike):
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 leave that to a different PR that fully types trio.Path
, can either continue with that in #2630 or open a different issue
Fixed all changes requested, except where noted. Good nitpicks @A5rocks! ❤️ |
648cdfc
to
10e7549
Compare
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.
Seems great from a cursory glance, we can always make a bunch of followups!
seeing exported symbols, and tests for seeing class members.
10e7549
to
d01f42e
Compare
f8646bb
to
c6ac460
Compare
Okay I'm done fighting with codecov, merging! |
For #2630