fsspec / universal_pathlib

pathlib api extended to use fsspec backends
MIT License
210 stars 36 forks source link

Static analysis of types broken in `>=0.2.0` #210

Closed bjhardcastle closed 2 weeks ago

bjhardcastle commented 3 months ago

Analyzing types with mypy was working before v0.2.0, now many attributes return Any.

If I run mypy on this .py file:

import typing
import upath

url = "https://github.com/fsspec/universal_pathlib/tree/main/upath"
root = upath.UPath(url, cache_type="first")
typing.reveal_type(root.glob('*'))
typing.reveal_type(root.iterdir())
typing.reveal_type(root.parent)
typing.reveal_type(root / 'README.md')

python: 3.11.5
mypy: 1.9.0
ap-- commented 3 months ago

Hi @bjhardcastle

Thank you for reporting the typing issue! I think it would be great if we'd run certain type checks together with the universal-pathlib test suite.

https://github.com/typeddjango/pytest-mypy-plugins seems to an interesting option for this.

I'll play around with it when I find some extra time.

-Andreas