fix bug in GenericText
This commit is contained in:
parent
096bfd2ae2
commit
25935f4350
1 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue