Skip to content

CAA, retries, documentation, workflows#2

Merged
zas merged 9 commits intomainfrom
caa
Mar 24, 2026
Merged

CAA, retries, documentation, workflows#2
zas merged 9 commits intomainfrom
caa

Conversation

@zas
Copy link
Copy Markdown
Owner

@zas zas commented Mar 24, 2026

No description provided.

zas added 9 commits March 24, 2026 12:36
New musicbrainzpy.coverart module with async CoverArtClient and
SyncCoverArtClient for the Cover Art Archive API:
- get_image_list / get_release_group_image_list (JSON listings)
- get_front / get_back / get_release_group_front (binary images)
- get_image (by numeric ID, with optional thumbnail size)
- Pydantic models: CoverArtImageList, CoverArtImage, Thumbnails
- Separate httpx client with follow_redirects for 307s
- Update migration guide with full CAA coverage
Add examples/cover_art.py showing cover art retrieval for
Sufjan Stevens — Carrie & Lowell (PDF booklet, PNG scans,
comments, diverse image types).

Add image_info() to both CoverArtClient and SyncCoverArtClient
for HEAD-based metadata (content-type, content-length) without
downloading the full image.

Fix CoverArtImage.id type to accept int (real API returns
integers, not strings as documented).
- New _retry module with async_retry/sync_retry helpers
- Exponential backoff on transient errors (httpx.TransportError,
  RateLimitedError) with configurable max_retries and base_delay
- Respect Retry-After header on 429/503 responses
- Map HTTP 429 to RateLimitedError (alongside existing 503)
- RateLimitedError now carries retry_after attribute
- Enable follow_redirects=True on both MB client httpx instances
  (CAA clients already had this)
- Rate limiter acquire() inside retry loop so retries respect rate limits
- All clients accept max_retries/retry_base_delay constructor params
Constructor args (app_name, app_version, app_contact) are now optional
and fall back to MUSICBRAINZPY_APP, MUSICBRAINZPY_VERSION,
MUSICBRAINZPY_CONTACT env vars. Raises ValueError if neither is set.

Also supports:
- MUSICBRAINZPY_BASE_URL — override API base URL
- MUSICBRAINZPY_USERNAME / MUSICBRAINZPY_PASSWORD — digest auth

Explicit constructor arguments always take precedence over env vars.
- README: add Cover Art Archive usage, env vars table, mention retry
- architecture.md: add new modules to layout (coverart, _retry,
  annotation/collection/coverart models), add retry/CAA/env vars sections
- api-reference.md: add retry behavior, Cover Art Archive endpoints,
  env vars table, note 429 alongside 503 for rate limiting
- Replace PEP 695 type parameter syntax (def func[T], class Foo[T])
  with TypeVar + Generic for 3.10 compatibility
- Replace StrEnum (3.11+) with str+Enum base class
- Update requires-python, classifiers, README, and migration guide
Test matrix: Python 3.10-3.14 on Linux, macOS, and Windows.
Runs pytest, ruff check, and ruff format.
@zas zas merged commit 67c6a15 into main Mar 24, 2026
15 checks passed
@zas zas deleted the caa branch March 24, 2026 12:30
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