Skip to content

Commit 66ccd3f

Browse files
committed
Pane(feat[split,split_window]): Add StrPath type support for start_directory
why: Standardize path handling to accept both str and PathLike objects what: - Import StrPath from libtmux._internal.types - Update start_directory parameter type annotations to StrPath | None - Update docstrings to reflect str or PathLike support - Fix logic pattern from 'is not None' to truthy check for proper command building - Clean up import organization
1 parent 7998363 commit 66ccd3f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libtmux/pane.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import typing as t
1414
import warnings
1515

16+
from libtmux import exc
17+
from libtmux._internal.types import StrPath
1618
from libtmux.common import has_gte_version, has_lt_version, tmux_cmd
1719
from libtmux.constants import (
1820
PANE_DIRECTION_FLAG_MAP,
@@ -23,8 +25,6 @@
2325
from libtmux.formats import FORMAT_SEPARATOR
2426
from libtmux.neo import Obj, fetch_obj
2527

26-
from . import exc
27-
2828
if t.TYPE_CHECKING:
2929
import sys
3030
import types
@@ -548,7 +548,7 @@ def split(
548548
self,
549549
/,
550550
target: int | str | None = None,
551-
start_directory: str | None = None,
551+
start_directory: StrPath | None = None,
552552
attach: bool = False,
553553
direction: PaneDirection | None = None,
554554
full_window_split: bool | None = None,
@@ -566,7 +566,7 @@ def split(
566566
attach : bool, optional
567567
make new window the current window after creating it, default
568568
True.
569-
start_directory : str, optional
569+
start_directory : str or PathLike, optional
570570
specifies the working directory in which the new window is created.
571571
direction : PaneDirection, optional
572572
split in direction. If none is specified, assume down.
@@ -668,7 +668,7 @@ def split(
668668

669669
tmux_args += ("-P", "-F{}".format("".join(tmux_formats))) # output
670670

671-
if start_directory is not None:
671+
if start_directory:
672672
# as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c.
673673
start_path = pathlib.Path(start_directory).expanduser()
674674
tmux_args += (f"-c{start_path}",)
@@ -870,7 +870,7 @@ def split_window(
870870
self,
871871
target: int | str | None = None,
872872
attach: bool = False,
873-
start_directory: str | None = None,
873+
start_directory: StrPath | None = None,
874874
vertical: bool = True,
875875
shell: str | None = None,
876876
size: str | int | None = None,
@@ -883,7 +883,7 @@ def split_window(
883883
----------
884884
attach : bool, optional
885885
Attach / select pane after creation.
886-
start_directory : str, optional
886+
start_directory : str or PathLike, optional
887887
specifies the working directory in which the new pane is created.
888888
vertical : bool, optional
889889
split vertically

0 commit comments

Comments
 (0)