Skip to content

fix: add AsyncResponse type to niquests response object#439

Merged
kyteinsky merged 2 commits into
mainfrom
fix/niquests-response-type
Jul 7, 2026
Merged

fix: add AsyncResponse type to niquests response object#439
kyteinsky merged 2 commits into
mainfrom
fix/niquests-response-type

Conversation

@kyteinsky

@kyteinsky kyteinsky commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request:

Summary by CodeRabbit

  • Refactor
    • Updated error handling to work consistently with both synchronous and asynchronous response objects, including broader support in the core exception classes and check_error.
  • Chores
    • Tightened the minimum supported niquests version requirement to 3.4.2 (still under the same major-version cap).

Signed-off-by: kyteinsky <kyteinsky@gmail.com>
@kyteinsky kyteinsky requested a review from oleksandr-nc June 2, 2026 14:14
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 148ae77b-d35f-479b-a48c-8dfcf2ca6296

📥 Commits

Reviewing files that changed from the base of the PR and between fb11527 and ca9356d.

📒 Files selected for processing (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

The exception module now accepts both synchronous and asynchronous response objects in its base exception, specialized exceptions, and error-checking helper. The project dependency constraint for niquests is also tightened to a newer minimum version.

Changes

Exception response type broadening

Layer / File(s) Summary
Base exception and import
nc_py_api/_exceptions.py
AsyncResponse is imported and NextcloudException accepts AsyncResponse | Response | None for its response field and constructor parameter.
Derived exceptions and check_error utility
nc_py_api/_exceptions.py
NextcloudExceptionNotModified, NextcloudExceptionNotFound, and NextcloudMissingCapabilities accept AsyncResponse | Response | None, and check_error() accepts AsyncResponse | Response.

Dependency version pin

Layer / File(s) Summary
Dependency version constraint
pyproject.toml
The niquests lower bound is updated from 3 to 3.4.2 while keeping the <4 upper bound.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: broadening niquests response handling to include AsyncResponse.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/niquests-response-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nc_py_api/_exceptions.py`:
- Line 3: The import may fail on older niquests releases because AsyncResponse
may not be re-exported; update the code to handle that by adding a fallback
import or pinning niquests: either pin niquests to a version known to export
AsyncResponse in your dependency manifest, or modify the import in
_exceptions.py to try the current top-level import of AsyncResponse, HTTPError,
Response and on ImportError fall back to the module path that actually defines
AsyncResponse (e.g., the internal async submodule) so the symbols AsyncResponse,
HTTPError, and Response are always available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 31cc61d6-8366-4c01-8b99-34108bbee9f6

📥 Commits

Reviewing files that changed from the base of the PR and between 9058723 and fb11527.

📒 Files selected for processing (1)
  • nc_py_api/_exceptions.py

Comment thread nc_py_api/_exceptions.py
"""Exceptions for the Nextcloud API."""

from niquests import HTTPError, Response
from niquests import AsyncResponse, HTTPError, Response

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Is AsyncResponse exported from the top-level niquests package (e.g. from niquests import AsyncResponse)? What niquests version added it?

💡 Result:

Yes. Niquests exports AsyncResponse from the top-level package, so from niquests import AsyncResponse works, as reflected in Niquests’ API documentation which lists AsyncResponse as an autoclass in the main API docs alongside the top-level interface. [1] Version: I could not find a specific release note/tag that explicitly states “exported AsyncResponse” or the version where AsyncResponse was introduced. However, Niquests’ HISTORY notes that AsyncSession “now returns a AsyncResponse when stream is set to True” (i.e., the async streaming response type existed by the time of that change), but the HISTORY snippet retrieved does not include the version number for that change. [2]

Citations:


_exceptions.py: from niquests import AsyncResponse appears to be a supported top-level export—Niquests’ API docs list AsyncResponse for the main package namespace, so this import should resolve. Since no exact “introduced in version X” release note was found, consider pinning a specific niquests version (or adding a fallback import) to avoid an ImportError if older 3.x releases ever lacked the re-export.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nc_py_api/_exceptions.py` at line 3, The import may fail on older niquests
releases because AsyncResponse may not be re-exported; update the code to handle
that by adding a fallback import or pinning niquests: either pin niquests to a
version known to export AsyncResponse in your dependency manifest, or modify the
import in _exceptions.py to try the current top-level import of AsyncResponse,
HTTPError, Response and on ImportError fall back to the module path that
actually defines AsyncResponse (e.g., the internal async submodule) so the
symbols AsyncResponse, HTTPError, and Response are always available.

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.67%. Comparing base (9058723) to head (fb11527).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #439   +/-   ##
=======================================
  Coverage   94.67%   94.67%           
=======================================
  Files          48       48           
  Lines        5636     5636           
=======================================
  Hits         5336     5336           
  Misses        300      300           
Files with missing lines Coverage Δ
nc_py_api/_exceptions.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

_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 <oleksandr2088@icloud.com>
@kyteinsky kyteinsky merged commit a343e7f into main Jul 7, 2026
10 of 14 checks passed
@kyteinsky kyteinsky deleted the fix/niquests-response-type branch July 7, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants