Skip to content

Commit 385a4ac

Browse files
committed
chore(shell): Typings for shell
1 parent 67e1548 commit 385a4ac

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/tmuxp/shell.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
"""
77
import logging
88
import os
9+
import typing as t
910

1011
logger = logging.getLogger(__name__)
1112

13+
if t.TYPE_CHECKING:
14+
from typing_extensions import Literal, TypeAlias
15+
16+
CLIShellLiteral: TypeAlias = Literal[
17+
"best", "pdb", "code", "ptipython", "ptpython", "ipython", "bpython"
18+
]
19+
1220

1321
def has_ipython() -> bool:
1422
try:
@@ -56,7 +64,7 @@ def has_bpython() -> bool:
5664
return True
5765

5866

59-
def detect_best_shell() -> str:
67+
def detect_best_shell() -> "CLIShellLiteral":
6068
if has_ptipython():
6169
return "ptipython"
6270
elif has_ptpython():
@@ -221,7 +229,10 @@ def launch_code():
221229

222230

223231
def launch(
224-
shell: str = "best", use_pythonrc: bool = False, use_vi_mode: bool = False, **kwargs
232+
shell: t.Optional["CLIShellLiteral"] = "best",
233+
use_pythonrc: bool = False,
234+
use_vi_mode: bool = False,
235+
**kwargs
225236
) -> None:
226237
# Also allowing passing shell='code' to force using code.interact
227238
imported_objects = get_launch_args(**kwargs)

0 commit comments

Comments
 (0)