diff --git a/HISTORY.md b/HISTORY.md index 2c986f45..8d5166e0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # cloudpathlib Changelog +## UNRELEASED + +- Fixed mypy 2.x type errors in `Client` and `CloudPath` that caused CI lint failures (Issue [#563](https://github.com/drivendataorg/cloudpathlib/issues/563), PR [#566](https://github.com/drivendataorg/cloudpathlib/pull/566)) + ## v0.24.0 (2026-04-29) - Added support for S3 Multi-Region Access Point (MRAP) URLs in `S3Path` (Issue [#556](https://github.com/drivendataorg/cloudpathlib/issues/556), PR [#557](https://github.com/drivendataorg/cloudpathlib/pull/557)) - Added support for Pydantic serialization (Issue [#537](https://github.com/drivendataorg/cloudpathlib/issues/537), PR [#538](https://github.com/drivendataorg/cloudpathlib/pull/538)) diff --git a/cloudpathlib/client.py b/cloudpathlib/client.py index a91c1557..d1c36fd5 100644 --- a/cloudpathlib/client.py +++ b/cloudpathlib/client.py @@ -4,7 +4,7 @@ from pathlib import Path import shutil from tempfile import TemporaryDirectory -from typing import Generic, Callable, Iterable, Optional, Tuple, TypeVar, Union +from typing import ClassVar, Generic, Callable, Iterable, Optional, Tuple, TypeVar, Union from .cloudpath import CloudImplementation, CloudPath, implementation_registry from .enums import FileCacheMode @@ -27,7 +27,7 @@ def decorator(cls: type) -> type: class Client(abc.ABC, Generic[BoundedCloudPath]): _cloud_meta: CloudImplementation - _default_client = None + _default_client: ClassVar[Optional["Client[BoundedCloudPath]"]] = None def __init__( self, @@ -95,7 +95,7 @@ def __del__(self) -> None: self._local_cache_dir.rmdir() @classmethod - def get_default_client(cls) -> "Client": + def get_default_client(cls) -> "Client[BoundedCloudPath]": """Get the default client, which the one that is used when instantiating a cloud path instance for this cloud without a client specified. """ diff --git a/cloudpathlib/cloudpath.py b/cloudpathlib/cloudpath.py index 00cc99ef..8a2a6dc4 100644 --- a/cloudpathlib/cloudpath.py +++ b/cloudpathlib/cloudpath.py @@ -907,8 +907,10 @@ def _dispatch_to_path(self, func: str, *args, **kwargs) -> Any: sequence_class = ( type(path_version) if not isinstance(path_version, _PathParents) else tuple ) - return sequence_class( # type: ignore - self._new_cloudpath(_resolve(p)) for p in path_version if _resolve(p) != p.root + return sequence_class( # type: ignore[call-arg] + self._new_cloudpath(_resolve(p)) + for p in path_version + if isinstance(p, PurePosixPath) and _resolve(p) != p.root ) # when pathlib returns something else, we probably just want that thing