-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathcolors.py
More file actions
31 lines (21 loc) · 688 Bytes
/
colors.py
File metadata and controls
31 lines (21 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Helper module so we don't have to install types-termcolor in CI.
This is imported by `mypy_test.py` and `stubtest_third_party.py`.
"""
from typing import TYPE_CHECKING
if TYPE_CHECKING:
def colored(__str: str, __style: str) -> str:
...
else:
try:
from termcolor import colored
except ImportError:
def colored(s: str, _: str) -> str:
return s
def print_error(error: str, end: str = "\n") -> None:
error_split = error.split("\n")
for line in error_split[:-1]:
print(colored(line, "red"))
print(colored(error_split[-1], "red"), end=end)
def print_success_msg() -> None:
print(colored("success", "green"))