Improve NonStreamable.print_msg performance

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
nathom 2021-07-15 13:37:20 -07:00
parent 07d0df382b
commit 4f99b62f25

View file

@ -35,13 +35,16 @@ class NonStreamable(Exception):
print(self.print_msg(item)) print(self.print_msg(item))
def print_msg(self, item) -> str: def print_msg(self, item) -> str:
base_msg = click.style(f"Unable to stream {item!s}.", fg="yellow") base_msg = [click.style(f"Unable to stream {item!s}.", fg="yellow")]
if self.message: if self.message:
base_msg += click.style(" Message: ", fg="yellow") + click.style( base_msg.extend(
self.message, fg="red" (
click.style("Message:", fg="yellow"),
click.style(self.message, fg="red"),
)
) )
return base_msg return " ".join(base_msg)
class InvalidContainerError(Exception): class InvalidContainerError(Exception):