Skip to content

Commit 9bc2344

Browse files
committed
fix: Fix remaining types in translator
1 parent 77f3560 commit 9bc2344

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

deepl/api_data.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def team_document(self) -> Detail:
279279
"""Returns usage details for documents shared among your team."""
280280
return self._team_document
281281

282-
def __str__(self):
282+
def __str__(self) -> str:
283283
details: List[Tuple[str, Usage.Detail]] = [
284284
("Characters", self.character),
285285
("Documents", self.document),
@@ -312,7 +312,7 @@ def __str__(self):
312312
return self.code
313313

314314
@staticmethod
315-
def remove_regional_variant(language: Union[str]) -> str:
315+
def remove_regional_variant(language: Union[str, "Language"]) -> str:
316316
"""Removes the regional variant from a language, e.g. EN-US gives EN"""
317317
return str(language).upper()[0:2]
318318

deepl/translator.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,12 @@ def translate_document_download(
732732
)
733733

734734
if output_file:
735-
for chunk in response.iter_content(chunk_size=chunk_size):
735+
chunks = (
736+
response.iter_content(chunk_size=chunk_size)
737+
if isinstance(response, requests.Response)
738+
else [response]
739+
)
740+
for chunk in chunks:
736741
output_file.write(chunk)
737742
return None
738743
else:

0 commit comments

Comments
 (0)