Skip to content

Commit

Permalink
upath.implementations.cloud: move empty bucket checks to subclasses (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- authored Sep 8, 2024
1 parent ddb2296 commit 0f40d6c
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions upath/implementations/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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)")

0 comments on commit 0f40d6c

Please sign in to comment.