Skip to content

Commit 12febed

Browse files
committed
session.py(refactor): Remove pre-3.2 version guards
why: tmux >= 3.2a is now required, these version checks are unnecessary what: - Remove has_version("2.7") BSD error workaround in rename_session() - Remove has_gte_version("3.0") check in new_window() - always pass -e environment flags - Remove has_gte_version("3.2") check for direction flags - always pass direction - Remove has_gte_version("3.2") check for target_window - always use target - Remove version skip comment from doctest examples - Remove unused has_gte_version and has_version imports
1 parent 6369987 commit 12febed

File tree

1 file changed

+5
-36
lines changed

1 file changed

+5
-36
lines changed

src/libtmux/session.py

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
EnvironmentMixin,
2626
WindowDict,
2727
handle_option_error,
28-
has_gte_version,
29-
has_version,
3028
session_check_name,
3129
)
3230

@@ -569,16 +567,7 @@ def rename_session(self, new_name: str) -> Session:
569567
proc = self.cmd("rename-session", new_name)
570568

571569
if proc.stderr:
572-
if has_version("2.7") and "no current client" in proc.stderr:
573-
"""tmux 2.7 raises "no current client" warning on BSD systems.
574-
575-
Should be fixed next release:
576-
577-
- https://www.mail-archive.com/tech@openbsd.org/msg45186.html
578-
- https://marc.info/?l=openbsd-cvs&m=152183263526828&w=2
579-
"""
580-
else:
581-
raise exc.LibTmuxException(proc.stderr)
570+
raise exc.LibTmuxException(proc.stderr)
582571

583572
self.refresh()
584573

@@ -636,11 +625,6 @@ def new_window(
636625
637626
Examples
638627
--------
639-
.. ::
640-
>>> import pytest
641-
>>> from libtmux.common import has_lt_version
642-
>>> if has_lt_version('3.2'):
643-
... pytest.skip('direction doctests require tmux 3.2 or newer')
644628
>>> window_initial = session.new_window(window_name='Example')
645629
>>> window_initial
646630
Window(@... 2:Example, Session($1 libtmux_...))
@@ -689,33 +673,18 @@ def new_window(
689673
window_args += ("-n", window_name)
690674

691675
if environment:
692-
if has_gte_version("3.0"):
693-
for k, v in environment.items():
694-
window_args += (f"-e{k}={v}",)
695-
else:
696-
logger.warning(
697-
"Environment flag ignored, requires tmux 3.0 or newer.",
698-
)
676+
for k, v in environment.items():
677+
window_args += (f"-e{k}={v}",)
699678

700679
if direction is not None:
701-
if has_gte_version("3.2"):
702-
window_args += (WINDOW_DIRECTION_FLAG_MAP[direction],)
703-
else:
704-
logger.warning(
705-
"Direction flag ignored, requires tmux 3.1 or newer.",
706-
)
680+
window_args += (WINDOW_DIRECTION_FLAG_MAP[direction],)
707681

708682
target: str | None = None
709683
if window_index is not None:
710684
# empty string for window_index will use the first one available
711685
target = f"{self.session_id}:{window_index}"
712686
if target_window:
713-
if has_gte_version("3.2"):
714-
target = target_window
715-
else:
716-
logger.warning(
717-
"Window target ignored, requires tmux 3.1 or newer.",
718-
)
687+
target = target_window
719688
elif window_index is not None:
720689
# empty string for window_index will use the first one available
721690
window_args += (f"-t{self.session_id}:{window_index}",)

0 commit comments

Comments
 (0)