Upgrade longwei to 2.0 (context manager pattern) #40

Merged
coding-agent-marvin8 merged 0 commits from refs/pull/40/head into main 2026-06-11 23:29:49 +00:00
coding-agent-marvin8 commented 2026-06-11 23:08:03 +00:00 (Migrated from codeberg.org)

Closes #39

Summary

  • Upgrades longwei from ~=1.5.1 to >=2.0,<3
  • Removes the direct httpx dependency (now managed internally by longwei 2.0 via httpx2)
  • FediHelper.connect(): drops AsyncClient construction and the client= arg; passes http2=True, timeout=30 directly to APClient.create()
  • FediHelper.aclose(): drops AsyncClient.aclose() in favour of APClient.close(); removes the client field from the struct
  • wizard.collect_mastodon_config(): removes the async with AsyncClient wrapper and client= args from the three static auth methods
  • Tests updated to match the new API (TDD-first)
Closes #39 ## Summary - Upgrades `longwei` from `~=1.5.1` to `>=2.0,<3` - Removes the direct `httpx` dependency (now managed internally by longwei 2.0 via httpx2) - `FediHelper.connect()`: drops `AsyncClient` construction and the `client=` arg; passes `http2=True, timeout=30` directly to `APClient.create()` - `FediHelper.aclose()`: drops `AsyncClient.aclose()` in favour of `APClient.close()`; removes the `client` field from the struct - `wizard.collect_mastodon_config()`: removes the `async with AsyncClient` wrapper and `client=` args from the three static auth methods - Tests updated to match the new API (TDD-first)
coding-agent-marvin8 commented 2026-06-11 23:25:25 +00:00 (Migrated from codeberg.org)

src/fedinesia/wizard.py line 57@marvin8

Removed the client parameter from APClient.create_app() without specifying http2 and timeout.

🔴 Not actionable. The three static auth methods in longwei 2.0 do not accept http2 or timeout parameters — confirmed by reading the source signatures in longwei/_mixin_auth.py:

async def create_app(instance_url, user_agent=..., client_website=...) -> tuple[str, str]
async def validate_authorization_code(instance_url, authorization_code, client_id, client_secret) -> str
async def generate_authorization_url(instance_url, client_id, user_agent=...) -> str

These methods manage their own internal HTTP client; the settings are not exposed. Additionally, generate_authorization_url makes no HTTP request at all — it constructs a URL locally. APClient.create() (the main runtime client used by FediHelper) does receive http2=True, timeout=30. The lack of these settings on the auth methods is an upstream design decision in longwei 2.0 with no workaround.

[`src/fedinesia/wizard.py` line 57](https://codeberg.org/marvinsmastodontools/fedinesia/pulls/40#issuecomment-17324753) — @marvin8 > Removed the `client` parameter from `APClient.create_app()` without specifying `http2` and `timeout`. 🔴 Not actionable. The three static auth methods in longwei 2.0 do not accept `http2` or `timeout` parameters — confirmed by reading the source signatures in `longwei/_mixin_auth.py`: ```python async def create_app(instance_url, user_agent=..., client_website=...) -> tuple[str, str] async def validate_authorization_code(instance_url, authorization_code, client_id, client_secret) -> str async def generate_authorization_url(instance_url, client_id, user_agent=...) -> str ``` These methods manage their own internal HTTP client; the settings are not exposed. Additionally, `generate_authorization_url` makes no HTTP request at all — it constructs a URL locally. `APClient.create()` (the main runtime client used by `FediHelper`) does receive `http2=True, timeout=30`. The lack of these settings on the auth methods is an upstream design decision in longwei 2.0 with no workaround.
Sign in to join this conversation.
No description provided.