Skip to content

Commit 6a40f60

Browse files
committed
common.py(refactor): Bump TMUX_MIN_VERSION to 3.2a
why: tmux versions below 3.2a are no longer supported as of libtmux 0.49.0 what: - Change TMUX_MIN_VERSION from "1.8" to "3.2a" - Remove TMUX_SOFT_MIN_VERSION constant (no longer needed) - Remove _version_deprecation_checked flag - Remove _check_deprecated_version() function - Remove deprecation warning call from get_version() - Update has_minimum_version() docstring to reflect 3.2a requirement - Update error message to mention v0.48.x backport
1 parent 1df438a commit 6a40f60

File tree

1 file changed

+7
-39
lines changed

1 file changed

+7
-39
lines changed

src/libtmux/common.py

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,16 @@
2424

2525

2626
#: Minimum version of tmux required to run libtmux
27-
TMUX_MIN_VERSION = "1.8"
27+
TMUX_MIN_VERSION = "3.2a"
2828

2929
#: Most recent version of tmux supported
3030
TMUX_MAX_VERSION = "3.6"
3131

32-
#: Minimum version before deprecation warning is shown
33-
TMUX_SOFT_MIN_VERSION = "3.2a"
34-
3532
SessionDict = dict[str, t.Any]
3633
WindowDict = dict[str, t.Any]
3734
WindowOptionDict = dict[str, t.Any]
3835
PaneDict = dict[str, t.Any]
3936

40-
#: Flag to ensure deprecation warning is only shown once per process
41-
_version_deprecation_checked: bool = False
42-
43-
44-
def _check_deprecated_version(version: LooseVersion) -> None:
45-
"""Check if tmux version is deprecated and warn once.
46-
47-
This is called from get_version() on first invocation.
48-
"""
49-
global _version_deprecation_checked
50-
if _version_deprecation_checked:
51-
return
52-
_version_deprecation_checked = True
53-
54-
import os
55-
import warnings
56-
57-
if os.environ.get("LIBTMUX_SUPPRESS_VERSION_WARNING"):
58-
return
59-
60-
if version < LooseVersion(TMUX_SOFT_MIN_VERSION):
61-
warnings.warn(
62-
f"tmux {version} is deprecated and will be unsupported in a future "
63-
f"libtmux release. Please upgrade to tmux {TMUX_SOFT_MIN_VERSION} "
64-
"or newer. Set LIBTMUX_SUPPRESS_VERSION_WARNING=1 to suppress this "
65-
"warning.",
66-
FutureWarning,
67-
stacklevel=4,
68-
)
69-
7037

7138
class EnvironmentMixin:
7239
"""Mixin for manager session and server level environment variables in tmux."""
@@ -336,9 +303,7 @@ def get_version() -> LooseVersion:
336303

337304
version = re.sub(r"[a-z-]", "", version)
338305

339-
version_obj = LooseVersion(version)
340-
_check_deprecated_version(version_obj)
341-
return version_obj
306+
return LooseVersion(version)
342307

343308

344309
def has_version(version: str) -> bool:
@@ -422,7 +387,7 @@ def has_lt_version(max_version: str) -> bool:
422387

423388

424389
def has_minimum_version(raises: bool = True) -> bool:
425-
"""Return True if tmux meets version requirement. Version >1.8 or above.
390+
"""Return True if tmux meets version requirement. Version >= 3.2a.
426391
427392
Parameters
428393
----------
@@ -441,6 +406,9 @@ def has_minimum_version(raises: bool = True) -> bool:
441406
442407
Notes
443408
-----
409+
.. versionchanged:: 0.49.0
410+
Minimum version bumped to 3.2a. For older tmux, use libtmux v0.48.x.
411+
444412
.. versionchanged:: 0.7.0
445413
No longer returns version, returns True or False
446414
@@ -454,7 +422,7 @@ def has_minimum_version(raises: bool = True) -> bool:
454422
msg = (
455423
f"libtmux only supports tmux {TMUX_MIN_VERSION} and greater. This "
456424
f"system has {get_version()} installed. Upgrade your tmux to use "
457-
"libtmux."
425+
"libtmux, or use libtmux v0.48.x for older tmux versions."
458426
)
459427
raise exc.VersionTooLow(msg)
460428
return False

0 commit comments

Comments
 (0)