Skip to content

Static analysis of types broken in >=0.2.0 #210

@bjhardcastle

Description

@bjhardcastle

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

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions