Repository navigation
fix(types): keep raw_transcription_config values and rebuild transcript.config from them - #288
Open
RishavTiwari25 wants to merge 3 commits into
Open
RishavTiwari25 wants to merge 3 commits into
RishavTiwari25 wants to merge 3 commits into
Conversation
…pt.config from them TranscriptionConfig(raw_transcription_config=raw) assigned every constructor argument onto raw, so their None defaults erased nearly all of raw's values. Transcript.config passed the response's fields as constructor arguments, which raised for a transcript with custom_spelling (the API returns a list of from/to objects, the argument is a dict) or language_detection_results (not an argument at all). It now builds a RawTranscriptionConfig and passes that.
Take upstream's assemblyai/__version__.py (1.9.0); the branch's own 1.8.3 bump is superseded.
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
Two related bugs in
TranscriptionConfig/Transcript.config.1.
TranscriptionConfig(raw_transcription_config=raw)erased almost all ofraw's values.The constructor stored
rawand then ran every setter (self.language_code = language_code,self.punctuate = punctuate, ...) with the arguments'Nonedefaults, writing straight ontoraw. Soand
rawitself was mutated tolanguage_code=None, punctuate=None. The docstring says explicit arguments should take priority over the raw config, not wipe it.2.
transcript.configraised for some completed transcripts.config_from_responsepassed the response's fields asTranscriptionConfig(**fields). That breaks when a field's API shape differs from the constructor argument, or the field is not an argument at all:custom_spelling: the API echoes[{"from": [...], "to": "..."}], butset_custom_spellingexpects a{to: from}dict ->AttributeError: 'list' object has no attribute 'items'.language_detection_results: aRawTranscriptionConfigfield but not a constructor argument ->TypeError: unexpected keyword argument.Changes
assemblyai/types.py: the constructor applies the explicit arguments to a freshRawTranscriptionConfig, then copies only the non-Noneones onto the passedraw_transcription_config(explicit arguments still win) and keeps that object.assemblyai/prerecorded/v2/_base.py:config_from_responsebuilds aRawTranscriptionConfigfrom the response fields and passes it asraw_transcription_config(this relies on fix 1).assemblyai/__version__.py: 1.8.2 -> 1.8.3 for the version bump check.Tests
tests/unit/test_config.py: raw values are kept (incl.punctuate=Falseandcustom_spelling); explicit arguments override raw values while the rest are kept.tests/unit/test_transcript.py:transcript.configfor a response withcustom_spellingand one withlanguage_detection_results.All four fail on
masterand pass with the fix.pytest tests/unit: 923 passed, 1 failure that also fails onmasteron Windows (test_upload_request_omits_content_length_for_an_unsized_stream, unrelated).ruff check/ruff format --checkclean on the changed files; mypy reports no new errors.