From 55cea8ea7f0cdc56fffd63ffaeaa9e08ef79d848 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 14 May 2019 18:55:47 +0000 Subject: [PATCH] Fix AttributedText types --- cheuph/markup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cheuph/markup.py b/cheuph/markup.py index 8ed55d8..9e86a96 100644 --- a/cheuph/markup.py +++ b/cheuph/markup.py @@ -261,7 +261,7 @@ class AttributedText: return blocks - def split_by(self, attribute_name: str) -> List[Tuple[Any, "AttributedText"]]: + def split_by(self, attribute_name: str) -> List[Tuple["AttributedText", Any]]: blocks = [] chunks: List[Chunk] = [] @@ -288,6 +288,10 @@ class AttributedText: return blocks def join(self, segments: Iterable["AttributedText"]) -> "AttributedText": + # Lazy and inefficient solution to the fact that segments can be any + # Iterable. TODO: Optimize, if this becomes a bottleneck. + segments = list(segments) + interspersed = segments[:1] for segment in segments[1:]: interspersed.append(self)