$ show alexdelorenzo/aiopath
aiopath is a drop-in asynchronous replacement for Python's standard library `pathlib`, providing `AsyncPath` and `AsyncPurePath` classes. It replicates the complete `pathlib` API but makes all I/O-bound methods (like `.exists()`, `.read_text()`, `.glob()`, `.mkdir()`) awaitable, allowing non-blocking filesystem operations in asyncio or trio applications. The library builds on `anyio.to_thread` for executing blocking OS calls off the event loop and `aiofile` for async file handles. It strictly inherits from `pathlib.Path` and `PurePath`, preserving method signatures, docstrings (via a metadata decorator), and class hierarchy. The implementation is clean and type-annotated throughout, requiring Python 3.12+ and using modern syntax like `type` aliases. Old compatibility layers (for Python 3.9-) are kept in `src/aiopath/old/` alongside stale backup files, indicating an ongoing renovation to drop legacy support.
The LLM identified 2 files worth highlighting for reuse:
Provides reusable utilities to convert synchronous callables into async functions using `anyio.to_thread`. Exports `to_thread()`, `func_to_async_func()`, `method_to_async_method()`, and `to_async_method()` with full type-parameter support (`Callable[P, T] -> Awaitable[T]`). This module is self-contained (no internal imports beyond `functools` and `anyio`) and can be extracted as a general-purpose async bridge for any blocking Python function.
Implements async file I/O with `IterableAIOFile` (an `AIOFile` subclass supporting async iteration line-by-line) and the `get_handle()` async context manager which wraps `anyio.open_file`. Provides helper functions `read_lines()` and `read_full_file()` for chunked, offset-based reading. This module is mostly self-contained (imports only from `aiopath.types` and third-party libs) and demonstrates a reusable pattern for async file reading with cursor tracking.