1010env_server_url = "DEEPL_SERVER_URL"
1111
1212
13- def main ():
13+ def main () -> None :
1414 auth_key = os .getenv (env_auth_key )
1515 server_url = os .getenv (env_server_url )
1616 if auth_key is None :
@@ -20,30 +20,34 @@ def main():
2020 )
2121
2222 # Create a Translator object, and call get_usage() to validate connection
23- translator = deepl .Translator (auth_key , server_url = server_url )
24- translator .get_usage ()
23+ translator : deepl .Translator = deepl .Translator (
24+ auth_key , server_url = server_url
25+ )
26+ u : deepl .Usage = translator .get_usage ()
27+ u .any_limit_exceeded
2528
2629 # Use most translation features of the library
27- translator .translate_text (
30+ _ = translator .translate_text (
2831 ["I am an example sentence" , "I am another sentence" ],
2932 source_lang = "EN" ,
3033 target_lang = "FR" ,
3134 formality = deepl .Formality .DEFAULT ,
3235 tag_handling = None ,
3336 )
34- ginfo = translator .create_glossary (
37+ ginfo : deepl . GlossaryInfo = translator .create_glossary (
3538 "Test Glossary" , "DE" , "FR" , {"Hallo" : "Bonjour" }
3639 )
3740 with io .BytesIO () as output_file :
38- translator .translate_document (
41+ doc_status : deepl . DocumentStatus = translator .translate_document (
3942 "My example document" ,
4043 output_file ,
4144 source_lang = "DE" ,
4245 target_lang = "FR" ,
4346 filename = "example.txt" ,
4447 glossary = ginfo ,
4548 )
46- translator .translate_text_with_glossary (
49+ doc_status .done
50+ _ = translator .translate_text_with_glossary (
4751 ["Ich bin ein Beispielsatz." , "Ich bin noch ein Satz." ], glossary = ginfo
4852 )
4953
0 commit comments