Uh oh!
There was an error while loading. Please reload this page.
refactor(api): share request helpers between the sync and async transports - #223
Closed
he-james wants to merge 1 commit into
Closed
refactor(api): share request helpers between the sync and async transports#223he-james wants to merge 1 commit into
he-james wants to merge 1 commit into
Conversation
…ports Prepare for an asyncio transcriber. This commit does not change behavior. - api: move the status checks into `_raise_for_status`. Add helpers for the request bodies and the query params. Both transports now raise the same exception type and message for each endpoint. - client: move the header and pool-limit code into module helpers. `AsyncClient` then uses the same user-agent, auth header, and keepalive. - _transcript_fields: move the response accessors from `Transcript` into a `TranscriptFields` mixin. The mixin reads an abstract `_response()`. This also deletes the repeated None checks. Tests: `pytest tests/unit` gives 382 passed, 3 failed. The 3 failures need `pyaudio` and also fail on master. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jchang-assemblyai
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Files changed
assemblyai/api.py_raise_for_status. New helpers build the request bodies and the query params.assemblyai/client.py_build_headersand_build_limits.assemblyai/transcriber.pyTranscriptmove into the new mixin. Net 228 lines removed.assemblyai/_transcript_fields.pyTranscriptFieldsmixin andconfig_from_response.Why
An asyncio transport would repeat many pieces of code.
_raise_for_statusholds both, so the two paths cannot diverge.Transcripthas 27 properties that read a fetchedTranscriptResponse. None of them perform I/O. Both transcript classes can therefore share them. A subclass implements_response().