Skip to content

Commit b4e8d20

Browse files
committed
pane.py(refactor): Remove pre-3.2 version guards
why: tmux >= 3.2a is now required, version guards for older tmux are unnecessary. what: - Remove has_gte_version("3.1") percentage checks in resize() - percentages always allowed - Remove has_lt_version("3.1") size flag branching in split() - always use -l flag - Remove has_gte_version("3.0") environment check in split() - -e flag always available - Simplify nested if statements after removing version checks - Remove unused has_gte_version, has_lt_version imports
1 parent fb48dce commit b4e8d20

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

src/libtmux/pane.py

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import warnings
1515

1616
from libtmux import exc
17-
from libtmux.common import has_gte_version, has_lt_version, tmux_cmd
17+
from libtmux.common import tmux_cmd
1818
from libtmux.constants import (
1919
PANE_DIRECTION_FLAG_MAP,
2020
RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP,
@@ -275,20 +275,21 @@ def resize(
275275
elif height or width:
276276
# Manual resizing
277277
if height:
278-
if isinstance(height, str):
279-
if height.endswith("%") and not has_gte_version("3.1"):
280-
raise exc.VersionTooLow
281-
if not height.isdigit() and not height.endswith("%"):
282-
raise exc.RequiresDigitOrPercentage
278+
if (
279+
isinstance(height, str)
280+
and not height.isdigit()
281+
and not height.endswith("%")
282+
):
283+
raise exc.RequiresDigitOrPercentage
283284
tmux_args += (f"-y{height}",)
284285

285286
if width:
286-
if isinstance(width, str):
287-
if width.endswith("%") and not has_gte_version("3.1"):
288-
raise exc.VersionTooLow
289-
if not width.isdigit() and not width.endswith("%"):
290-
raise exc.RequiresDigitOrPercentage
291-
287+
if (
288+
isinstance(width, str)
289+
and not width.isdigit()
290+
and not width.endswith("%")
291+
):
292+
raise exc.RequiresDigitOrPercentage
292293
tmux_args += (f"-x{width}",)
293294
elif zoom:
294295
# Zoom / Unzoom
@@ -650,16 +651,7 @@ def split(
650651
tmux_args += tuple(PANE_DIRECTION_FLAG_MAP[PaneDirection.Below])
651652

652653
if size is not None:
653-
if has_lt_version("3.1"):
654-
if isinstance(size, str) and size.endswith("%"):
655-
tmux_args += (f"-p{str(size).rstrip('%')}",)
656-
else:
657-
warnings.warn(
658-
'Ignored size. Use percent in tmux < 3.1, e.g. "size=50%"',
659-
stacklevel=2,
660-
)
661-
else:
662-
tmux_args += (f"-l{size}",)
654+
tmux_args += (f"-l{size}",)
663655

664656
if full_window_split:
665657
tmux_args += ("-f",)
@@ -678,13 +670,8 @@ def split(
678670
tmux_args += ("-d",)
679671

680672
if environment:
681-
if has_gte_version("3.0"):
682-
for k, v in environment.items():
683-
tmux_args += (f"-e{k}={v}",)
684-
else:
685-
logger.warning(
686-
"Environment flag ignored, tmux 3.0 or newer required.",
687-
)
673+
for k, v in environment.items():
674+
tmux_args += (f"-e{k}={v}",)
688675

689676
if shell:
690677
tmux_args += (shell,)

0 commit comments

Comments
 (0)