From 25935f43503e4364221050d0856e9c73a80ce17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Tue, 8 Feb 2022 23:45:55 +0100 Subject: [PATCH] fix bug in GenericText --- PyTeX/format/generic_text.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/PyTeX/format/generic_text.py b/PyTeX/format/generic_text.py index 94a644a..27a9d72 100644 --- a/PyTeX/format/generic_text.py +++ b/PyTeX/format/generic_text.py @@ -1,3 +1,4 @@ +from __future__ import annotations from pathlib import Path from typing import Union, List, Optional @@ -83,7 +84,7 @@ class GenericText: else: return None - def __add__(self, other): + def __add__(self, other: Union[None, GenericText, List[str]]) -> GenericText: if not self.has_value(): return other if isinstance(other, GenericText): @@ -93,6 +94,16 @@ class GenericText: else: return GenericText(self.text + other) + def __iadd__(self, other: Union[None, GenericText, List[str]]) -> GenericText: + if not self.has_value(): + self.text = other + elif isinstance(other, GenericText): + if other.has_value(): + self.text += other.text + else: + self.text += other + return self + def __radd__(self, other): if other is None: return self