diff --git a/upath/implementations/cloud.py b/upath/implementations/cloud.py index 455fca6b..36f4029f 100644 --- a/upath/implementations/cloud.py +++ b/upath/implementations/cloud.py @@ -22,13 +22,6 @@ class CloudPath(UPath): __slots__ = () - def __init__( - self, *args, protocol: str | None = None, **storage_options: Any - ) -> None: - super().__init__(*args, protocol=protocol, **storage_options) - if not self.drive and len(self.parts) > 1: - raise ValueError("non key-like path provided (bucket/container missing)") - @classmethod def _transform_init_args( cls, @@ -71,6 +64,13 @@ def relative_to(self, other, /, *_deprecated, walk_up=False): class GCSPath(CloudPath): __slots__ = () + def __init__( + self, *args, protocol: str | None = None, **storage_options: Any + ) -> None: + super().__init__(*args, protocol=protocol, **storage_options) + if not self.drive and len(self.parts) > 1: + raise ValueError("non key-like path provided (bucket/container missing)") + def mkdir( self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False ) -> None: @@ -84,6 +84,20 @@ def mkdir( class S3Path(CloudPath): __slots__ = () + def __init__( + self, *args, protocol: str | None = None, **storage_options: Any + ) -> None: + super().__init__(*args, protocol=protocol, **storage_options) + if not self.drive and len(self.parts) > 1: + raise ValueError("non key-like path provided (bucket/container missing)") + class AzurePath(CloudPath): __slots__ = () + + def __init__( + self, *args, protocol: str | None = None, **storage_options: Any + ) -> None: + super().__init__(*args, protocol=protocol, **storage_options) + if not self.drive and len(self.parts) > 1: + raise ValueError("non key-like path provided (bucket/container missing)")