From fb115279b6e80890fd9dfd1f6cf794f3a5629fa5 Mon Sep 17 00:00:00 2001 From: kyteinsky Date: Tue, 2 Jun 2026 14:45:16 +0200 Subject: [PATCH 1/2] fix: add AsyncResponse type to niquests response object Signed-off-by: kyteinsky --- nc_py_api/_exceptions.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/nc_py_api/_exceptions.py b/nc_py_api/_exceptions.py index c7524bfe..d2f5a39f 100644 --- a/nc_py_api/_exceptions.py +++ b/nc_py_api/_exceptions.py @@ -1,6 +1,6 @@ """Exceptions for the Nextcloud API.""" -from niquests import HTTPError, Response +from niquests import AsyncResponse, HTTPError, Response class NextcloudException(Exception): @@ -9,9 +9,15 @@ class NextcloudException(Exception): status_code: int reason: str info: str - response: Response | None - - def __init__(self, status_code: int = 0, reason: str = "", info: str = "", response: Response | None = None): + response: AsyncResponse | Response | None + + def __init__( + self, + status_code: int = 0, + reason: str = "", + info: str = "", + response: AsyncResponse | Response | None = None, + ): super(BaseException, self).__init__() self.status_code = status_code self.reason = reason @@ -27,25 +33,25 @@ def __str__(self): class NextcloudExceptionNotModified(NextcloudException): """The exception indicates that there is no need to retransmit the requested resources.""" - def __init__(self, reason="Not modified", info: str = "", response: Response | None = None): + def __init__(self, reason="Not modified", info: str = "", response: AsyncResponse | Response | None = None): super().__init__(304, reason=reason, info=info, response=response) class NextcloudExceptionNotFound(NextcloudException): """The exception that is thrown during operations when the object is not found.""" - def __init__(self, reason="Not found", info: str = "", response: Response | None = None): + def __init__(self, reason="Not found", info: str = "", response: AsyncResponse | Response | None = None): super().__init__(404, reason=reason, info=info, response=response) class NextcloudMissingCapabilities(NextcloudException): """The exception that is thrown when required capability for API is missing.""" - def __init__(self, reason="Missing capability", info: str = "", response: Response | None = None): + def __init__(self, reason="Missing capability", info: str = "", response: AsyncResponse | Response | None = None): super().__init__(412, reason=reason, info=info, response=response) -def check_error(response: Response, info: str = ""): +def check_error(response: AsyncResponse | Response, info: str = ""): """Checks HTTP code from Nextcloud, and raises exception in case of error. For the OCS and DAV `code` be code returned by HTTP and not the status from ``ocs_meta``. From ca9356d9f6c6e2df9481bb8e2b103f4f205e2291 Mon Sep 17 00:00:00 2001 From: Oleksandr Piskun Date: Tue, 7 Jul 2026 11:59:26 +0000 Subject: [PATCH 2/2] fix(deps): require niquests>=3.4.2 for AsyncResponse import _exceptions.py now imports AsyncResponse, which niquests first exposed as a top-level export in 3.4.2 (absent in 3.0.0 to 3.4.1). The previous niquests>=3 floor would let `import nc_py_api` fail with ImportError on older niquests, so raise the floor to match. Signed-off-by: Oleksandr Piskun --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2bab1cf8..5b7477ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ dynamic = [ dependencies = [ "fastapi>=0.133", "filelock>=3.20.3,<4", - "niquests>=3,<4", + "niquests>=3.4.2,<4", "pydantic>=2.1.1", "python-dotenv>=1", "starlette>=1.0.1",