Upgrade longwei to 2.0 (context manager pattern) #39

Closed
opened 2026-06-11 23:04:25 +00:00 by coding-agent-marvin8 · 1 comment
coding-agent-marvin8 commented 2026-06-11 23:04:25 +00:00 (Migrated from codeberg.org)

longwei 2.0 removes the public httpx.AsyncClient parameter from its API. The library now manages its own HTTP client internally (backed by httpx2 instead of httpx).

Currently fedinesia:

  • Creates an httpx.AsyncClient and passes it via client= to APClient.create() in FediHelper.connect()
  • Passes client= to APClient.create_app() and APClient.validate_authorization_code() in wizard.py
  • Owns the httpx dependency directly

All three of these patterns are broken in longwei 2.0.

longwei 2.0 removes the public httpx.AsyncClient parameter from its API. The library now manages its own HTTP client internally (backed by httpx2 instead of httpx). Currently fedinesia: - Creates an httpx.AsyncClient and passes it via client= to APClient.create() in FediHelper.connect() - Passes client= to APClient.create_app() and APClient.validate_authorization_code() in wizard.py - Owns the httpx dependency directly All three of these patterns are broken in longwei 2.0.
coding-agent-marvin8 commented 2026-06-11 23:04:39 +00:00 (Migrated from codeberg.org)

Findings

longwei 2.0 breaking changes affecting fedinesia:

  1. APClient.create() — client= param removed; pass http2=True/timeout=N directly
  2. create_app() and validate_authorization_code() — client= param removed
  3. Resource cleanup — APClient is now an async context manager; await ap.close() is the non-CM alternative

Plan

fedi.py — FediHelper:

  • Drop from httpx import AsyncClient
  • Remove client: AsyncClient | None = None field from the Struct
  • connect(): remove AsyncClient() construction, add http2=True, timeout=30 directly to APClient.create(), drop client= arg
  • aclose(): replace await self.client.aclose() with await self.instance.close()

wizard.py — collect_mastodon_config:

  • Drop from httpx import AsyncClient
  • Remove the async with AsyncClient(http2=True) as client: wrapper
  • Drop client= from create_app() and validate_authorization_code() calls

pyproject.toml:

  • longwei~=1.5.1 → longwei>=2.0,<3
  • Remove httpx[http2] (no longer used directly)

Tests updated TDD-first before each implementation change.

Branch: feat/issue-39-longwei-2-upgrade

## Findings longwei 2.0 breaking changes affecting fedinesia: 1. APClient.create() — client= param removed; pass http2=True/timeout=N directly 2. create_app() and validate_authorization_code() — client= param removed 3. Resource cleanup — APClient is now an async context manager; await ap.close() is the non-CM alternative ## Plan **fedi.py — FediHelper:** - Drop from httpx import AsyncClient - Remove client: AsyncClient | None = None field from the Struct - connect(): remove AsyncClient() construction, add http2=True, timeout=30 directly to APClient.create(), drop client= arg - aclose(): replace await self.client.aclose() with await self.instance.close() **wizard.py — collect_mastodon_config:** - Drop from httpx import AsyncClient - Remove the async with AsyncClient(http2=True) as client: wrapper - Drop client= from create_app() and validate_authorization_code() calls **pyproject.toml:** - longwei~=1.5.1 → longwei>=2.0,<3 - Remove httpx[http2] (no longer used directly) **Tests updated TDD-first** before each implementation change. Branch: feat/issue-39-longwei-2-upgrade
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
marvin8/fedinesia#39
No description provided.