summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-10-27 12:10:45 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-10-27 12:10:45 -0400
commitd2c97338d395f4ce2439cf6ccde0aabac413d959 (patch)
tree1a898cd927629345a948955c6b453147e6acffcf /cmd2
parent0d60017ba650ce2c8eedf2de7317477292e80056 (diff)
downloadcmd2-git-d2c97338d395f4ce2439cf6ccde0aabac413d959.tar.gz
Added type checks to ansi.style()
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/ansi.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd2/ansi.py b/cmd2/ansi.py
index 5517ecf0..29d09fff 100644
--- a/cmd2/ansi.py
+++ b/cmd2/ansi.py
@@ -970,6 +970,8 @@ def style(
:param overline: apply the overline style if True. Defaults to False.
:param strikethrough: apply the strikethrough style if True. Defaults to False.
:param underline: apply the underline style if True. Defaults to False.
+ :raises: TypeError if fg isn't None or a subclass of FgColor
+ :raises: TypeError if bg isn't None or a subclass of BgColor
:return: the stylized string
"""
# List of strings that add style
@@ -980,10 +982,14 @@ def style(
# Process the style settings
if fg is not None:
+ if not isinstance(fg, FgColor):
+ raise TypeError("fg must be a subclass of FgColor")
additions.append(fg)
removals.append(Fg.RESET)
if bg is not None:
+ if not isinstance(bg, BgColor):
+ raise TypeError("bg must a subclass of BgColor")
additions.append(bg)
removals.append(Bg.RESET)