-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
Publicly expose AsyncIOWrapper
#2864
Conversation
AsyncIOWrapper
AsyncIOWrapper
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2864 +/- ##
=======================================
Coverage 99.64% 99.64%
=======================================
Files 116 116
Lines 17503 17504 +1
Branches 3148 3149 +1
=======================================
+ Hits 17441 17442 +1
Misses 43 43
Partials 19 19
|
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 to me at least.
How do I fix the errors |
Probably similar to what you did for the |
Would it be a good idea to expose this? The way it works is kinda complicated, and I imagine we might need to change those hints at some point - exposing it means we're saying it's a more stable API. Also users using it as a type hint means they don't accept any "native" file classes. Like the synchronous IO, it'd be better to define a protocol at the place you use it, with the methods you need. |
Did you read my usage case? I am trying to specifically handle asynchronous file objects in a function's arguments, and I have to resort to reaching into the internals of trio to type it properly, which I think is unacceptable. I am not intending on handling native synchronous file IO at all, only the async version. |
Yep, what I mean is that you should define a protocol, only include the methods you need, then annotate the function as accepting that. Then a class that doesn't inherit from the wrapper but does define appropriate methods will work. |
I'm blanking on this, not remembering what you are referring to by this |
Sorry, I just misread a0f58ea |
This PR exposes
_file_io.AsyncIOWrapper
to the public.I was working on a project of mine that has to use
trio.wrap_file
and calls a few functions that needed to take the returnedAsyncIOWrapper
object as a parameter, but when typing arguments for said functions I found thatAsyncIOWrapper
is not exposed publicly and the only way to type it properly would be to manually reach in totrio._file_io
and get it.