Fix type bug

This commit is contained in:
YishiMichael 2022-03-31 10:57:25 +08:00
parent fc4f649570
commit 461500637e
No known key found for this signature in database
GPG key ID: EC615C0C5A86BC80
2 changed files with 6 additions and 6 deletions

View file

@ -187,8 +187,9 @@ class LabelledString(_StringSVG):
inserted_string_pairs: list[tuple[Span, tuple[str, str]]],
other_repl_items: list[tuple[Span, str]]
) -> dict[Span, str]:
result = dict(other_repl_items)
if not inserted_string_pairs:
return other_repl_items.copy()
return result
indices, _, _, inserted_strings = zip(*sorted([
(
@ -200,12 +201,11 @@ class LabelledString(_StringSVG):
for span, str_pair in inserted_string_pairs
for flag in range(2)
]))
result = {
result.update({
(index, index): "".join(inserted_strings[slice(*item_span)])
for index, item_span
in LabelledString.compress_neighbours(indices)
}
result.update(other_repl_items)
})
return result
@staticmethod
@ -272,7 +272,7 @@ class LabelledString(_StringSVG):
return (0, len(self.string))
def get_space_spans(self) -> list[Span]:
return self.find_spans(r"\s+")
return self.find_spans(r"\s")
# Parsing

View file

@ -470,7 +470,7 @@ class MarkupText(LabelledString):
def get_label_span_list(self) -> list[Span]:
breakup_indices = remove_list_redundancies(list(it.chain(*it.chain(
self.space_spans,
self.find_spans(r"\s+"),
self.find_spans(r"\b"),
self.specified_spans
))))