@@ -100,7 +100,7 @@ def __init__(
100100 self ,
101101 src_lang ,
102102 target_lang ,
103- info : TranslateInfo = TranslateInfo () ,
103+ info : TranslateInfo | None = None ,
104104 chatbot_model : str | ModelConfig = "gpt-4.1-nano" ,
105105 fee_limit : float = 0.8 ,
106106 proxy : str | None = None ,
@@ -119,6 +119,8 @@ def __init__(
119119 base_url_config (Optional[dict]): Configuration for the base URL of the API.
120120 """
121121 super ().__init__ ()
122+ if info is None :
123+ info = TranslateInfo ()
122124 self .chatbot_model = chatbot_model
123125 self .info = info
124126 self .chatbot = self ._initialize_chatbot (chatbot_model , fee_limit , proxy , base_url_config )
@@ -149,9 +151,9 @@ def _parse_responses(self, resp) -> tuple[list[str], str, str]:
149151 translations = self ._extract_translations (content )
150152
151153 return [t .strip () for t in translations ], summary .strip (), scene .strip ()
152- except Exception as e :
154+ except Exception :
153155 logger .error (f"Failed to extract contents from response: { content } " )
154- raise e
156+ raise
155157
156158 def _extract_tag_content (self , content : str , tag : str ) -> str :
157159 """
@@ -203,7 +205,7 @@ def translate_chunk(
203205 self ,
204206 chunk_id : int ,
205207 chunk : list [tuple [int , str ]],
206- context : TranslationContext = TranslationContext () ,
208+ context : TranslationContext | None = None ,
207209 use_glossary : bool = True ,
208210 ) -> tuple [list [str ], TranslationContext ]:
209211 """
@@ -218,6 +220,8 @@ def translate_chunk(
218220 Returns:
219221 Tuple[List[str], TranslationContext]: The translated texts and updated context.
220222 """
223+ if context is None :
224+ context = TranslationContext ()
221225 user_input = self .prompter .format_texts (chunk )
222226 guideline = context .guideline if use_glossary else context .non_glossary_guideline
223227 messages_list = [
@@ -251,7 +255,7 @@ def __init__(
251255 self ,
252256 src_lang ,
253257 target_lang ,
254- info : TranslateInfo = TranslateInfo () ,
258+ info : TranslateInfo | None = None ,
255259 chatbot_model : str | ModelConfig = "gpt-4.1-nano" ,
256260 retry_model : str | ModelConfig | None = None ,
257261 fee_limit : float = 0.8 ,
@@ -272,6 +276,8 @@ def __init__(
272276 base_url_config (Optional[dict]): Configuration for the base URL of the API.
273277 """
274278 super ().__init__ ()
279+ if info is None :
280+ info = TranslateInfo ()
275281 self .src_lang = src_lang
276282 self .target_lang = target_lang
277283 self .info = info
@@ -426,7 +432,7 @@ def __init__(
426432 self ,
427433 src_lang ,
428434 target_lang ,
429- info : TranslateInfo = TranslateInfo () ,
435+ info : TranslateInfo | None = None ,
430436 chatbot_model : str | ModelConfig = "gpt-4.1-nano" ,
431437 fee_limit : float = 0.8 ,
432438 proxy : str | None = None ,
@@ -445,6 +451,8 @@ def __init__(
445451 base_url_config (Optional[dict]): Configuration for the base URL of the API.
446452 """
447453 super ().__init__ ()
454+ if info is None :
455+ info = TranslateInfo ()
448456 self .src_lang = src_lang
449457 self .target_lang = target_lang
450458 self .info = info
0 commit comments