Async-first helpers, typed base classes and a large collection of filesystems for fsspec and universal-pathlib.
📖 Documentation: https://phil65.github.io/upathtools/
uv add upathtools
# optional backends are extras, e.g.
uv add "upathtools[httpx,sqlite,mcp]"Requires Python 3.13+.
import asyncio
from upathtools import AsyncUPath, list_files, read_folder
async def main() -> None:
path = AsyncUPath("notes/hello.txt")
await path.parent.amkdir(parents=True, exist_ok=True)
await path.awrite_text("Hello from upathtools!")
print(await path.aread_text())
# Read many files concurrently (works for any fsspec protocol: s3://, gcs://, ...)
files = await read_folder("notes", pattern="**/*.txt")
for name, content in files.items():
print(name, len(content))
print(await list_files("notes", pattern="**/*.txt"))
asyncio.run(main())Filesystems can be used directly or combined:
from upathtools.filesystems import IsolatedMemoryFileSystem, PackageFileSystem, UnionFileSystem
pkg = PackageFileSystem("upathtools") # browse an installed package's modules
print(pkg.get_upath("helpers").read_text()[:34])
docs = IsolatedMemoryFileSystem()
docs.pipe_file("/readme.md", b"# Hi")
union = UnionFileSystem({"pkg": pkg, "docs": docs}) # mount filesystems side by side
print(union.ls("/", detail=False)) # ['pkg', 'docs']
print(union.cat_file("docs/readme.md"))AsyncUPath: async versions of theUPathAPI (aread_text,awrite_bytes,aiterdir,aglob,acopy, ...), falling back to threads for sync filesystems.- Batch operations:
read_folder,list_files,read_folder_as_text,read_path,fsspec_grepwith parallel loading. - Typed base classes:
BaseAsyncFileSystem[TPath, TInfoDict],BaseUPath[TInfoDict],WrapperFileSystem,BaseAsyncFileFileSystemfor building your own filesystems with typed info dicts,get_upath(),get_tree()and a shell-likecli("grep TODO . -r"). - Filesystems (registered as fsspec / UPath protocols via entry points):
- file contents: Markdown sections, SQLite tables, tree-sitter code, OpenAPI and JSON Schema specs
- Python: installed packages (
pkg://), distributions, Pydantic models and instances - remote: HTTP (httpx2), GitHub Gists / Issues / Wiki, GitLab, Linear, Notion, Appwrite, MCP resources and tools
- sandboxes: E2B, Modal, Daytona, Beam, Vercel, Cloudflare, Microsandbox, HopX, Sprites, Codex, SRT
- combining: union (mount points), flat union (merged view), overlay (layered writes),
delegating (
file.md::Sectionaccess into files)
upathtools_config: lightweight pydantic models describing filesystems (FilesystemConfigTypediscriminated union) withcreate_fs().- Helpers:
to_upath,upath_to_fs,copy,write_file,multi_glob, directory trees, pydanticUPathfield types.
MIT