Skip to content

Commit 794ddd2

Browse files
committed
Add __add__ method for _ApplyStyle to allow combining multiple styles into one.
1 parent 37b047a commit 794ddd2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/string_builder.py

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ def __repr__(self):
1414
def __str__(self):
1515
return self.style
1616

17+
def __add__(self, other):
18+
if not isinstance(other, _ApplyStyle):
19+
raise TypeError
20+
else:
21+
return _ApplyStyle(f"{self.style} {other.style}")
22+
1723
def apply_style(self, *strings):
1824
braces = "{}" * len(strings)
1925
if self.style is not None:

0 commit comments

Comments
 (0)