Skip to content

Commit 89a5fcf

Browse files
committed
Fixed colors example code
1 parent d058752 commit 89a5fcf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/colors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def do_speak(self, args):
8383
self.poutput(output_str)
8484
self.perror('error message at the end')
8585

86-
@staticmethod
87-
def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
86+
# noinspection PyMethodMayBeStatic
87+
def perror(self, msg: Any = '', *, end: str = '\n', apply_style: bool = True) -> None:
8888
"""Override perror() method from `cmd2.Cmd`
8989
9090
Use colorama native approach for styling the text instead of `cmd2.ansi` methods
@@ -98,9 +98,9 @@ def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
9898
final_msg = "{}{}{}{}".format(Fore.RED, Back.YELLOW, msg, Style.RESET_ALL)
9999
else:
100100
final_msg = "{}".format(msg)
101-
ansi.ansi_aware_write(sys.stderr, final_msg + end)
101+
ansi.style_aware_write(sys.stderr, final_msg + end)
102102

103-
def do_timetravel(self, args):
103+
def do_timetravel(self, _):
104104
"""A command which always generates an error message, to demonstrate custom error colors"""
105105
self.perror('Mr. Fusion failed to start. Could not energize flux capacitor.')
106106

0 commit comments

Comments
 (0)