We use UPath in a project with mypy typing. Most functions and attributes are inferred properly, even without type annotations in upath. However, we had to create a stub to teach mypy the subclass relationship with pathlib.Path and declare fs and _kwargs attributes in a stub file (see below). Perhaps it would be easier for other users, if upath shipped with these stub file or has type annotations directly in the code. I'd be happy to help with a PR.
./stubs/upath/__init__.py:
from pathlib import Path
from typing import Any, Dict
import fsspec
class UPath(Path):
fs: fsspec.AbstractFileSystem
_kwargs: Dict[str, Any]
We use
UPath
in a project withmypy
typing. Most functions and attributes are inferred properly, even without type annotations inupath
. However, we had to create a stub to teachmypy
the subclass relationship withpathlib.Path
and declarefs
and_kwargs
attributes in a stub file (see below). Perhaps it would be easier for other users, ifupath
shipped with these stub file or has type annotations directly in the code. I'd be happy to help with a PR../stubs/upath/__init__.py
: