@@ -127,22 +127,28 @@ def __init__(self, **kwargs):
127127 self .translation : Union [str , List [str ], List [TextBlock ]]
128128 self .adapted_to : Optional [List [str ]] = kwargs .get ('adapted_to' , None )
129129 self .glossaries : Optional [List [str ]] = kwargs .get ('glossaries' , None )
130- self .adapted_to_matches : Optional [Union [List [NGMemoryMatch ], List [List [NGMemoryMatch ]]]] = None
131- self .glossaries_matches : Optional [Union [List [NGGlossaryMatch ], List [List [NGGlossaryMatch ]]]] = None
130+ self .adapted_to_matches : Optional [Union [List [NGMemoryMatch ], List [Optional [ List [NGMemoryMatch ] ]]]] = None
131+ self .glossaries_matches : Optional [Union [List [NGGlossaryMatch ], List [Optional [ List [NGGlossaryMatch ] ]]]] = None
132132
133133 # Parse adapted_to_matches
134134 adapted_to_matches = kwargs .get ('adapted_to_matches' , None )
135135 if adapted_to_matches is not None :
136- if adapted_to_matches and isinstance (adapted_to_matches [0 ], list ):
137- self .adapted_to_matches = [[NGMemoryMatch (** m ) for m in matches ] for matches in adapted_to_matches ]
136+ if any (isinstance (m , list ) for m in adapted_to_matches ):
137+ self .adapted_to_matches = [
138+ [NGMemoryMatch (** m ) for m in matches ] if isinstance (matches , list ) else None
139+ for matches in adapted_to_matches
140+ ]
138141 else :
139142 self .adapted_to_matches = [NGMemoryMatch (** m ) for m in adapted_to_matches ]
140143
141144 # Parse glossaries_matches
142145 glossaries_matches = kwargs .get ('glossaries_matches' , None )
143146 if glossaries_matches is not None :
144- if glossaries_matches and isinstance (glossaries_matches [0 ], list ):
145- self .glossaries_matches = [[NGGlossaryMatch (** m ) for m in matches ] for matches in glossaries_matches ]
147+ if any (isinstance (m , list ) for m in glossaries_matches ):
148+ self .glossaries_matches = [
149+ [NGGlossaryMatch (** m ) for m in matches ] if isinstance (matches , list ) else None
150+ for matches in glossaries_matches
151+ ]
146152 else :
147153 self .glossaries_matches = [NGGlossaryMatch (** m ) for m in glossaries_matches ]
148154
0 commit comments