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