fix(transcriber): accept bytes in transcribe/upload type hints#218
Open
ccampbell-aai wants to merge 1 commit into
Open
fix(transcriber): accept bytes in transcribe/upload type hints#218ccampbell-aai wants to merge 1 commit into
ccampbell-aai wants to merge 1 commit into
Conversation
The upload path (httpx content=) has always accepted raw bytes at runtime — an existing unit test even feeds os.urandom(10) through transcribe() — but the annotations said Union[str, BinaryIO], so type checkers rejected valid calls. Widen the data/audio_file parameters to Union[str, bytes, BinaryIO] across the public Transcriber methods and the internal upload path, and update docstrings. No behavior change; aligns with SyncTranscriber, which already documents bytes input. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
aurpsis-aai
approved these changes
Jul 25, 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 free
to 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.
Summary
Fixes #102.
The upload path (httpx
content=) has always accepted rawbytesat runtime — an existing unit test even feedsos.urandom(10)throughtranscribe()— but the annotations saidUnion[str, BinaryIO], so type checkers reject valid calls liketranscriber.transcribe(audio_bytes).This widens the
data/audio_fileparameters toUnion[str, bytes, BinaryIO]across the publicTranscribermethods (transcribe,transcribe_async,transcribe_group(_async),submit(_group),upload_file(_async)), the internal_TranscriberImplmethods, andapi.upload_file, plus docstring updates.No behavior change — this is a strict superset of the old types, and aligns the async
Transcriberhints withSyncTranscriber, which already documents bytes input.Testing
pytest tests/unit/test_transcriber.py— 29 passed (includes new parametrized annotation checks that fail pre-fix, plus a runtimetranscribe_groupbytes regression test)ruff==0.3.5format + check clean,mypy==1.5.1 --follow-imports=silent --ignore-missing-importsclean on both changed files🤖 Generated with Claude Code