Skip to content

Conversation

ap--
Copy link
Collaborator

@ap-- ap-- commented Oct 5, 2025

Related to #435

This at least restores mypy behavior but not ty.

Will evaluate the other typecheckers for another PR.

todo add as a typesafety test...

from typing import Any, reveal_type

from upath.core import UPath
from upath._chain import DEFAULT_CHAIN_PARSER

params: dict[str, Any] = {}

path2 = UPath("foo/bar/baz", protocol="s3")
reveal_type(path2)
resolved2 = path2.resolve()
reveal_type(resolved2)

path3 = UPath("foo/bar/baz", protocol="s3", **params)
reveal_type(path3)
resolved3 = path3.resolve()
reveal_type(resolved3)

path0 = UPath("/foo/bar/baz", protocol="file")
reveal_type(path0)
resolved0 = path0.resolve()
reveal_type(resolved0)

path1 = UPath("/foo/bar/baz", protocol="file", **params)
reveal_type(path1)

resolved1 = path1.resolve()
reveal_type(resolved1)
uv run mypy --cache-dir=/dev/null --no-incremental upath-435.py
upath-435.py:9: note: Revealed type is "upath.implementations.cloud.S3Path"
upath-435.py:11: note: Revealed type is "upath.implementations.cloud.S3Path"
upath-435.py:14: note: Revealed type is "upath.implementations.cloud.S3Path"
upath-435.py:16: note: Revealed type is "upath.implementations.cloud.S3Path"
upath-435.py:19: note: Revealed type is "upath.implementations.local.FilePath"
upath-435.py:21: note: Revealed type is "upath.implementations.local.FilePath"
upath-435.py:24: note: Revealed type is "upath.implementations.local.FilePath"
upath-435.py:27: note: Revealed type is "upath.implementations.local.FilePath"
Success: no issues found in 1 source file

@ap-- ap-- marked this pull request as ready for review October 8, 2025 20:15
@ap-- ap-- linked an issue Oct 8, 2025 that may be closed by this pull request
@ap-- ap-- merged commit 57f6a54 into fsspec:main Oct 8, 2025
27 checks passed
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 this pull request may close these issues.

UPath(...) detected as type Any in 0.3.2

1 participant