Skip to content

v2.7.1: 优化 async 重试配置; 改造 batch download 返回值类型; IndexedEntity 继承 Sequence 以支持标准切片协议.#546

Merged
hect0x7 merged 4 commits into
masterfrom
dev
Jul 4, 2026
Merged

v2.7.1: 优化 async 重试配置; 改造 batch download 返回值类型; IndexedEntity 继承 Sequence 以支持标准切片协议.#546
hect0x7 merged 4 commits into
masterfrom
dev

Conversation

@hect0x7

@hect0x7 hect0x7 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added clearer download result objects for single and batch downloads, making outcomes easier to inspect.
  • Bug Fixes
    • Batch downloads now return an aggregated result that records per-item failures while keeping successful items.
    • Improved indexing and slice handling for paginated/search results (bounds-safe slicing, negative indices, and consistent IndexError behavior).
    • Retry settings now respect an explicit 0 value instead of using the default.
  • Chores
    • Updated the package version to 2.7.1.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f5389c2-2cad-4fc4-9f15-ea2f13e43ae8

📥 Commits

Reviewing files that changed from the base of the PR and between aa74af5 and 75a4cb1.

📒 Files selected for processing (1)
  • src/jmcomic/api.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/jmcomic/api.py

📝 Walkthrough

Walkthrough

This PR changes download APIs to return DownloadResult and BatchResult objects, records batch failures per item, adjusts async retry handling for falsey values, and updates IndexedEntity to support Sequence-style slicing and negative indexing with tests.

Changes

Download result and batch handling

Layer / File(s) Summary
Result types
src/jmcomic/jm_downloader.py
Adds DownloadResult and BatchResult types used by the download APIs.
Single download returns
src/jmcomic/api.py
download_album, download_photo, and async variants return DownloadResult objects.
Batch download aggregation
src/jmcomic/api.py
download_batch and download_batch_async return BatchResult values and store per-item exceptions in failed.
Async retry count
src/jmcomic/jm_async_client.py
retry_times now preserves falsey non-None values instead of forcing 5.

IndexedEntity Sequence and slicing fix

Layer / File(s) Summary
Sequence indexing and tests
src/jmcomic/jm_entity.py, tests/test_jmcomic/test_jm_client.py
IndexedEntity subclasses Sequence, normalizes slice and negative index access, and is covered by a new indexing test.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant download_batch
  participant _safe_download
  participant BatchResult

  Caller->>download_batch: request batch download
  download_batch->>BatchResult: create result
  loop each parsed id
    download_batch->>_safe_download: call download_api
    alt success
      _safe_download->>BatchResult: add(DownloadResult)
    else exception
      _safe_download->>BatchResult: failed[id] = exception
    end
  end
  download_batch-->>Caller: return BatchResult
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: version bump, async retry tweak, batch download return type changes, and Sequence support for IndexedEntity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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 `@src/jmcomic/api.py`:
- Around line 33-42: The batch download flow currently marks items as successful
too early via the internal callback in _safe_download and download_api, which
can leave partially failed items in both the success set and result.failed.
Update the success bookkeeping so add() or equivalent success recording happens
only after the single-item download has fully completed and
raise_if_has_exception() has passed, using the existing download_api, callback,
and BatchResult/result.failed flow to keep total and iteration consistent.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 57d78563-190a-4ed1-aa53-3a8e92cb9136

📥 Commits

Reviewing files that changed from the base of the PR and between 15b4cbb and aa74af5.

📒 Files selected for processing (6)
  • src/jmcomic/__init__.py
  • src/jmcomic/api.py
  • src/jmcomic/jm_async_client.py
  • src/jmcomic/jm_downloader.py
  • src/jmcomic/jm_entity.py
  • tests/test_jmcomic/test_jm_client.py

Comment thread src/jmcomic/api.py Outdated
@hect0x7 hect0x7 merged commit 2866026 into master Jul 4, 2026
6 checks passed
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.

1 participant