Skip to content

Commit 22e598a

Browse files
authored
Fix HTTPPath error handling for unsupported methods (#518)
* upath.implementations.http: adjust write error cases * upath.implementations.http: fix error handling on HTTPPath.touch
1 parent 76d5b55 commit 22e598a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

upath/implementations/http.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from fsspec.asyn import sync
1212

13+
from upath import UnsupportedOperation
1314
from upath._stat import UPathStatResult
1415
from upath.core import UPath
1516
from upath.types import JoinablePathLike
@@ -124,3 +125,29 @@ def resolve(
124125
break
125126

126127
return resolved_path
128+
129+
def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None:
130+
raise UnsupportedOperation
131+
132+
def mkdir(
133+
self,
134+
mode: int = 0o777,
135+
parents: bool = False,
136+
exist_ok: bool = False,
137+
) -> None:
138+
raise UnsupportedOperation
139+
140+
def unlink(self, missing_ok: bool = False) -> None:
141+
raise UnsupportedOperation
142+
143+
def write_bytes(self, data: bytes) -> int:
144+
raise UnsupportedOperation("DataPath does not support writing")
145+
146+
def write_text(
147+
self,
148+
data: str,
149+
encoding: str | None = None,
150+
errors: str | None = None,
151+
newline: str | None = None,
152+
) -> int:
153+
raise UnsupportedOperation("DataPath does not support writing")

0 commit comments

Comments
 (0)