Skip to content

Commit bc0dec5

Browse files
Bug fix
1 parent eae12dd commit bc0dec5

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/lara_sdk/_translator.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)