Skip to content

fix(transcriber): accept bytes in transcribe/upload type hints#218

Open
ccampbell-aai wants to merge 1 commit into
masterfrom
ccampbell/fix/issue-102
Open

fix(transcriber): accept bytes in transcribe/upload type hints#218
ccampbell-aai wants to merge 1 commit into
masterfrom
ccampbell/fix/issue-102

Conversation

@ccampbell-aai

Copy link
Copy Markdown
Contributor

Summary

Fixes #102.

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 reject valid calls like transcriber.transcribe(audio_bytes).

This widens the data/audio_file parameters to Union[str, bytes, BinaryIO] across the public Transcriber methods (transcribe, transcribe_async, transcribe_group(_async), submit(_group), upload_file(_async)), the internal _TranscriberImpl methods, and api.upload_file, plus docstring updates.

No behavior change — this is a strict superset of the old types, and aligns the async Transcriber hints with SyncTranscriber, 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 runtime transcribe_group bytes regression test)
  • Mirrored CI locally: ruff==0.3.5 format + check clean, mypy==1.5.1 --follow-imports=silent --ignore-missing-imports clean on both changed files

🤖 Generated with Claude Code

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>
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.

Accept bytes as argument

2 participants