Repository navigation
Publicly expose AsyncIOWrapper - #2864
CoolCat467 wants to merge 15 commits into
Conversation
AsyncIOWrapperAsyncIOWrapper
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
|
A5rocks
left a comment
There was a problem hiding this comment.
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.AsyncIOWrapperto the public.I was working on a project of mine that has to use
trio.wrap_fileand calls a few functions that needed to take the returnedAsyncIOWrapperobject as a parameter, but when typing arguments for said functions I found thatAsyncIOWrapperis not exposed publicly and the only way to type it properly would be to manually reach in totrio._file_ioand get it.