Skip to content

Commit fb11527

Browse files
committed
fix: add AsyncResponse type to niquests response object
Signed-off-by: kyteinsky <kyteinsky@gmail.com>
1 parent 9058723 commit fb11527

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

nc_py_api/_exceptions.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Exceptions for the Nextcloud API."""
22

3-
from niquests import HTTPError, Response
3+
from niquests import AsyncResponse, HTTPError, Response
44

55

66
class NextcloudException(Exception):
@@ -9,9 +9,15 @@ class NextcloudException(Exception):
99
status_code: int
1010
reason: str
1111
info: str
12-
response: Response | None
13-
14-
def __init__(self, status_code: int = 0, reason: str = "", info: str = "", response: Response | None = None):
12+
response: AsyncResponse | Response | None
13+
14+
def __init__(
15+
self,
16+
status_code: int = 0,
17+
reason: str = "",
18+
info: str = "",
19+
response: AsyncResponse | Response | None = None,
20+
):
1521
super(BaseException, self).__init__()
1622
self.status_code = status_code
1723
self.reason = reason
@@ -27,25 +33,25 @@ def __str__(self):
2733
class NextcloudExceptionNotModified(NextcloudException):
2834
"""The exception indicates that there is no need to retransmit the requested resources."""
2935

30-
def __init__(self, reason="Not modified", info: str = "", response: Response | None = None):
36+
def __init__(self, reason="Not modified", info: str = "", response: AsyncResponse | Response | None = None):
3137
super().__init__(304, reason=reason, info=info, response=response)
3238

3339

3440
class NextcloudExceptionNotFound(NextcloudException):
3541
"""The exception that is thrown during operations when the object is not found."""
3642

37-
def __init__(self, reason="Not found", info: str = "", response: Response | None = None):
43+
def __init__(self, reason="Not found", info: str = "", response: AsyncResponse | Response | None = None):
3844
super().__init__(404, reason=reason, info=info, response=response)
3945

4046

4147
class NextcloudMissingCapabilities(NextcloudException):
4248
"""The exception that is thrown when required capability for API is missing."""
4349

44-
def __init__(self, reason="Missing capability", info: str = "", response: Response | None = None):
50+
def __init__(self, reason="Missing capability", info: str = "", response: AsyncResponse | Response | None = None):
4551
super().__init__(412, reason=reason, info=info, response=response)
4652

4753

48-
def check_error(response: Response, info: str = ""):
54+
def check_error(response: AsyncResponse | Response, info: str = ""):
4955
"""Checks HTTP code from Nextcloud, and raises exception in case of error.
5056
5157
For the OCS and DAV `code` be code returned by HTTP and not the status from ``ocs_meta``.

0 commit comments

Comments
 (0)