@@ -168,6 +168,7 @@ async def _localize_chunk(
168168 Localized chunk
169169 """
170170 await self ._ensure_client ()
171+ assert self ._client is not None # Type guard for mypy
171172 url = urljoin (self .config .api_url , "/i18n" )
172173
173174 request_data = {
@@ -418,6 +419,7 @@ async def recognize_locale(self, text: str) -> str:
418419 raise ValueError ("Text cannot be empty" )
419420
420421 await self ._ensure_client ()
422+ assert self ._client is not None # Type guard for mypy
421423 url = urljoin (self .config .api_url , "/recognize" )
422424
423425 try :
@@ -447,6 +449,7 @@ async def whoami(self) -> Optional[Dict[str, str]]:
447449 Dictionary with 'email' and 'id' keys, or None if not authenticated
448450 """
449451 await self ._ensure_client ()
452+ assert self ._client is not None # Type guard for mypy
450453 url = urljoin (self .config .api_url , "/whoami" )
451454
452455 try :
@@ -589,19 +592,22 @@ async def quick_batch_translate(
589592 }
590593
591594 async with cls (config ) as engine :
592- params = {
593- "source_locale" : source_locale ,
594- "fast" : fast ,
595- }
596-
597595 if isinstance (content , str ):
598- params ["target_locales" ] = target_locales
599- return await engine .batch_localize_text (content , params )
596+ batch_params = {
597+ "source_locale" : source_locale ,
598+ "target_locales" : target_locales ,
599+ "fast" : fast ,
600+ }
601+ return await engine .batch_localize_text (content , batch_params )
600602 elif isinstance (content , dict ):
601603 # For objects, run concurrent translations to each target locale
602604 tasks = []
603605 for target_locale in target_locales :
604- task_params = {** params , "target_locale" : target_locale }
606+ task_params = {
607+ "source_locale" : source_locale ,
608+ "target_locale" : target_locale ,
609+ "fast" : fast ,
610+ }
605611 task = engine .localize_object (content , task_params , concurrent = True )
606612 tasks .append (task )
607613 return await asyncio .gather (* tasks )
0 commit comments