Repository navigation
Expose AsyncIOWrapper publicly - #3512
arian-bozorgzad wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3512 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19454 19461 +7
Branches 1321 1322 +1
===============================================
+ Hits 19454 19461 +7
🚀 New features to boost your workflow:
|
|
@A5rocks |
A5rocks
left a comment
There was a problem hiding this comment.
Sorry for the wait! Please don't mention me elsewhere to get my attention.
| @@ -0,0 +1,3 @@ | |||
| :class:`trio.AsyncIOWrapper` is now public, so values returned by | |||
| :func:`trio.open_file`, :func:`trio.wrap_file`, and :meth:`trio.Path.open` can | |||
| be annotated without importing from the private ``trio._file_io`` module. | |||
There was a problem hiding this comment.
No need for the without importing from ....
There was a problem hiding this comment.
Not convinced this file tests anything beyond what src/trio/_tests/type_tests/path.py tests
| # instances. The file-I/O tests separately verify that the dynamic | ||
| # methods and the TYPE_CHECKING declarations stay in sync. |
| :func:`trio.wrap_file`, or :meth:`trio.Path.open`. The generic parameter | ||
| records the type of the wrapped synchronous file object, and the available | ||
| file operations follow that wrapped type. |
There was a problem hiding this comment.
The paragraph before this already mentions that this class exposes the file ops
This makes AsyncIOWrapper available as trio.AsyncIOWrapper, so it can be used to annotate values returned by open_file(), wrap_file(), and Path.open() without importing from the private _file_io module.
I added a short section to the docs as well, like including a note about using a protocol when only part of the async file interface is needed.
i also updated export test because AsyncIOWrapper has a slightly different static and runtime interface ,The test now checks that the difference is exactly the expected dynamic file methods before continuing with the normal export checks, and added type tests for open_file() and wrap_file().
and since AsyncIOWrapper exposes some file methods dynamically, I updated the export test to check that the difference between its static and runtime interfaces is exactly the expected set of dynamic methods.
Fixes #3390
python -m pytest src/trio/_tests/test_file_io.py
17 passed - 0 fails
python -m tox -e typing
mypy (linux): passed
mypy (darwin): passed
mypy (win32): passed
pyright: 0 errors