Skip to content

Commit 240272a

Browse files
committed
feat(cli[utils]): Extract CLIColour to type
1 parent f35a26f commit 240272a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/tmuxp/cli/utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from .. import log
66

7+
if t.TYPE_CHECKING:
8+
from typing_extensions import TypeAlias
9+
10+
CLIColour: TypeAlias = t.Union[int, t.Tuple[int, int, int], str]
11+
12+
713
logger = logging.getLogger(__name__)
814

915

@@ -184,14 +190,14 @@ def _interpret_color(
184190

185191

186192
class UnknownStyleColor(Exception):
187-
def __init__(self, color: str, *args: object, **kwargs: object) -> None:
193+
def __init__(self, color: "CLIColour", *args: object, **kwargs: object) -> None:
188194
return super().__init__(f"Unknown color {color!r}", *args, **kwargs)
189195

190196

191197
def style(
192198
text: t.Any,
193-
fg: t.Optional[t.Union[int, t.Tuple[int, int, int], str]] = None,
194-
bg: t.Optional[t.Union[int, t.Tuple[int, int, int], str]] = None,
199+
fg: t.Optional["CLIColour"] = None,
200+
bg: t.Optional["CLIColour"] = None,
195201
bold: t.Optional[bool] = None,
196202
dim: t.Optional[bool] = None,
197203
underline: t.Optional[bool] = None,

0 commit comments

Comments
 (0)