fix bug in GenericText

This commit is contained in:
Maximilian Keßler 2022-02-08 23:45:55 +01:00
parent 096bfd2ae2
commit 25935f4350

View file

@ -1,3 +1,4 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import Union, List, Optional from typing import Union, List, Optional
@ -83,7 +84,7 @@ class GenericText:
else: else:
return None return None
def __add__(self, other): def __add__(self, other: Union[None, GenericText, List[str]]) -> GenericText:
if not self.has_value(): if not self.has_value():
return other return other
if isinstance(other, GenericText): if isinstance(other, GenericText):
@ -93,6 +94,16 @@ class GenericText:
else: else:
return GenericText(self.text + other) 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): def __radd__(self, other):
if other is None: if other is None:
return self return self