Skip to content

Commit 0f40d6c

Browse files
authored
upath.implementations.cloud: move empty bucket checks to subclasses (#277)
1 parent ddb2296 commit 0f40d6c

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

upath/implementations/cloud.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
class CloudPath(UPath):
2323
__slots__ = ()
2424

25-
def __init__(
26-
self, *args, protocol: str | None = None, **storage_options: Any
27-
) -> None:
28-
super().__init__(*args, protocol=protocol, **storage_options)
29-
if not self.drive and len(self.parts) > 1:
30-
raise ValueError("non key-like path provided (bucket/container missing)")
31-
3225
@classmethod
3326
def _transform_init_args(
3427
cls,
@@ -71,6 +64,13 @@ def relative_to(self, other, /, *_deprecated, walk_up=False):
7164
class GCSPath(CloudPath):
7265
__slots__ = ()
7366

67+
def __init__(
68+
self, *args, protocol: str | None = None, **storage_options: Any
69+
) -> None:
70+
super().__init__(*args, protocol=protocol, **storage_options)
71+
if not self.drive and len(self.parts) > 1:
72+
raise ValueError("non key-like path provided (bucket/container missing)")
73+
7474
def mkdir(
7575
self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False
7676
) -> None:
@@ -84,6 +84,20 @@ def mkdir(
8484
class S3Path(CloudPath):
8585
__slots__ = ()
8686

87+
def __init__(
88+
self, *args, protocol: str | None = None, **storage_options: Any
89+
) -> None:
90+
super().__init__(*args, protocol=protocol, **storage_options)
91+
if not self.drive and len(self.parts) > 1:
92+
raise ValueError("non key-like path provided (bucket/container missing)")
93+
8794

8895
class AzurePath(CloudPath):
8996
__slots__ = ()
97+
98+
def __init__(
99+
self, *args, protocol: str | None = None, **storage_options: Any
100+
) -> None:
101+
super().__init__(*args, protocol=protocol, **storage_options)
102+
if not self.drive and len(self.parts) > 1:
103+
raise ValueError("non key-like path provided (bucket/container missing)")

0 commit comments

Comments
 (0)