Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotations to UPath #50

Closed
normanrz opened this issue Mar 20, 2022 · 0 comments · Fixed by #79
Closed

Add type annotations to UPath #50

normanrz opened this issue Mar 20, 2022 · 0 comments · Fixed by #79

Comments

@normanrz
Copy link
Collaborator

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant