universal_pathlib icon indicating copy to clipboard operation
universal_pathlib copied to clipboard

Static analysis of types broken in `>=0.2.0`

Open bjhardcastle opened this issue 1 year ago • 1 comments

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')
  • with 0.1.4:
scripts\test_types.py:6: note: Revealed type is "typing.Generator[upath.core.UPath, None, None]"
scripts\test_types.py:7: note: Revealed type is "typing.Generator[upath.core.UPath, None, None]"
scripts\test_types.py:8: note: Revealed type is "upath.core.UPath"
scripts\test_types.py:9: note: Revealed type is "upath.core.UPath"
  • with 0.2.2:
scripts\test_types.py:6: note: Revealed type is "Any"
scripts\test_types.py:7: note: Revealed type is "Any"
scripts\test_types.py:8: note: Revealed type is "Any"
scripts\test_types.py:9: note: Revealed type is "Any"

python: 3.11.5
mypy: 1.9.0

bjhardcastle avatar Mar 20 '24 00:03 bjhardcastle

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

ap-- avatar Mar 20 '24 21:03 ap--