Skip to content

Commit 59ba191

Browse files
committed
Fix mypy errors
1 parent 10a7793 commit 59ba191

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

assemblyai/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def lemur_purge_request_data(
358358
client: httpx.Client,
359359
request: types.LemurPurgeRequest,
360360
http_timeout: Optional[float],
361-
) -> types.LemurPurgeRequest:
361+
) -> types.LemurPurgeResponse:
362362
response = client.delete(
363363
f"{ENDPOINT_LEMUR_BASE}/{request.request_id}",
364364
timeout=http_timeout,
@@ -374,7 +374,7 @@ def lemur_purge_request_data(
374374

375375
def lemur_get_response_data(
376376
client: httpx.Client,
377-
request_id: int,
377+
request_id: str,
378378
http_timeout: Optional[float],
379379
) -> Union[
380380
types.LemurStringResponse,

assemblyai/lemur.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(
1212
self,
1313
*,
1414
client: _client.Client,
15-
sources: List[types.LemurSource],
15+
sources: Optional[List[types.LemurSource]],
1616
) -> None:
1717
self._client = client
1818

assemblyai/types.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class RawTranscriptionConfig(BaseModel):
521521
iab_categories: Optional[bool]
522522
"Enable Topic Detection."
523523

524-
custom_spelling: Optional[List[Dict[str, List[str]]]]
524+
custom_spelling: Optional[List[Dict[str, Union[str, List[str]]]]]
525525
"Customize how words are spelled and formatted using to and from values"
526526

527527
disfluencies: Optional[bool]
@@ -649,10 +649,11 @@ def __init__(
649649
speech_threshold: Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive.
650650
raw_transcription_config: Create the config from a `RawTranscriptionConfig`
651651
"""
652-
self._raw_transcription_config = raw_transcription_config
653-
654-
if raw_transcription_config is None:
655-
self._raw_transcription_config = RawTranscriptionConfig()
652+
self._raw_transcription_config = (
653+
raw_transcription_config
654+
if raw_transcription_config is not None
655+
else RawTranscriptionConfig()
656+
)
656657

657658
# explicit configurations have higher priority if `raw_transcription_config` has been passed as well
658659
self.language_code = language_code
@@ -914,17 +915,21 @@ def iab_categories(self, enable: Optional[bool]) -> None:
914915
self._raw_transcription_config.iab_categories = enable
915916

916917
@property
917-
def custom_spelling(self) -> Optional[Dict[str, List[str]]]:
918+
def custom_spelling(self) -> Optional[Dict[str, Union[str, List[str]]]]:
918919
"Returns the current set custom spellings."
919920

920921
if self._raw_transcription_config.custom_spelling is None:
921922
return None
922923

923924
custom_spellings = {}
924925
for custom_spelling in self._raw_transcription_config.custom_spelling:
925-
custom_spellings[custom_spelling["from"]] = custom_spelling["to"]
926+
_from = custom_spelling["from"]
927+
if isinstance(_from, str):
928+
custom_spellings[_from] = custom_spelling["to"]
929+
else:
930+
raise ValueError("`from` argument must be a string!")
926931

927-
return custom_spellings
932+
return custom_spellings if custom_spelling else None
928933

929934
@property
930935
def disfluencies(self) -> Optional[bool]:
@@ -938,8 +943,6 @@ def disfluencies(self, enable: Optional[bool]) -> None:
938943

939944
self._raw_transcription_config.disfluencies = enable
940945

941-
return self
942-
943946
@property
944947
def sentiment_analysis(self) -> Optional[bool]:
945948
"Returns the status of the Sentiment Analysis feature."
@@ -953,7 +956,7 @@ def sentiment_analysis(self, enable: Optional[bool]) -> None:
953956
self._raw_transcription_config.sentiment_analysis = enable
954957

955958
@property
956-
def auto_chapters(self) -> bool:
959+
def auto_chapters(self) -> Optional[bool]:
957960
"Returns the status of the Auto Chapters feature."
958961

959962
return self._raw_transcription_config.auto_chapters
@@ -971,7 +974,7 @@ def auto_chapters(self, enable: Optional[bool]) -> None:
971974
self._raw_transcription_config.auto_chapters = enable
972975

973976
@property
974-
def entity_detection(self) -> bool:
977+
def entity_detection(self) -> Optional[bool]:
975978
"Returns whether Entity Detection feature is enabled or not."
976979

977980
return self._raw_transcription_config.entity_detection
@@ -1076,7 +1079,7 @@ def set_casing_and_formatting(
10761079

10771080
def set_speaker_diarization(
10781081
self,
1079-
enable: bool = True,
1082+
enable: Optional[bool] = True,
10801083
speakers_expected: Optional[int] = None,
10811084
) -> Self:
10821085
"""
@@ -1261,7 +1264,7 @@ def set_custom_spelling(
12611264

12621265
def set_summarize(
12631266
self,
1264-
enable: bool = True,
1267+
enable: Optional[bool] = True,
12651268
model: Optional[SummarizationModel] = None,
12661269
type: Optional[SummarizationType] = None,
12671270
) -> Self:
@@ -1866,13 +1869,6 @@ def source(self) -> Sourcable:
18661869
"""
18671870
return self._source
18681871

1869-
@property
1870-
def context(self) -> Optional[Union[str, Dict[str, Any]]]:
1871-
"""
1872-
An optional context on the source (can be a string or an arbitrary dictionary)
1873-
"""
1874-
return self._context
1875-
18761872
@property
18771873
def type(self) -> LemurSourceType:
18781874
"""

0 commit comments

Comments
 (0)