Skip to content

Commit 1f3727e

Browse files
committed
!squash fix: rename _global to global_ in OptionsMixin
why: Python convention uses trailing underscore (global_) to avoid conflicts with reserved words, not leading underscore (_global). what: - Rename _global parameter to global_ across all methods - Update deprecation warning message to reference global_ - Update docstring reference to global_
1 parent 15ada3c commit 1f3727e

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/libtmux/options.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def set_option(
600600
601601
.. deprecated:: 0.28
602602
603-
Deprecated by ``g`` for global, use `_global`` instead.
603+
Deprecated by ``g`` for global, use `global_`` instead.
604604
605605
Raises
606606
------
@@ -667,7 +667,7 @@ def set_option(
667667
flags.append("-a")
668668

669669
if g is not None:
670-
warnings.warn("g argument is deprecated in favor of _global", stacklevel=2)
670+
warnings.warn("g argument is deprecated in favor of global_", stacklevel=2)
671671
global_ = g
672672

673673
if global_ is not None and global_:
@@ -696,7 +696,7 @@ def unset_option(
696696
self,
697697
option: str,
698698
unset_panes: bool | None = None,
699-
_global: bool | None = None,
699+
global_: bool | None = None,
700700
ignore_errors: bool | None = None,
701701
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
702702
) -> Self:
@@ -758,8 +758,8 @@ def unset_option(
758758
assert isinstance(ignore_errors, bool)
759759
flags.append("-q")
760760

761-
if _global is not None and _global:
762-
assert isinstance(_global, bool)
761+
if global_ is not None and global_:
762+
assert isinstance(global_, bool)
763763
flags.append("-g")
764764

765765
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -782,7 +782,7 @@ def unset_option(
782782
def _show_options_raw(
783783
self,
784784
g: bool | None = False,
785-
_global: bool | None = False,
785+
global_: bool | None = False,
786786
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
787787
include_hooks: bool | None = None,
788788
include_inherited: bool | None = None,
@@ -823,9 +823,9 @@ def _show_options_raw(
823823
flags: tuple[str, ...] = ()
824824

825825
if g:
826-
warnings.warn("g argument is deprecated in favor of _global", stacklevel=2)
826+
warnings.warn("g argument is deprecated in favor of global_", stacklevel=2)
827827
flags += ("-g",)
828-
elif _global:
828+
elif global_:
829829
flags += ("-g",)
830830

831831
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -843,7 +843,7 @@ def _show_options_raw(
843843
def _show_options_dict(
844844
self,
845845
g: bool | None = False,
846-
_global: bool | None = False,
846+
global_: bool | None = False,
847847
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
848848
include_hooks: bool | None = None,
849849
include_inherited: bool | None = None,
@@ -879,7 +879,7 @@ def _show_options_dict(
879879
True
880880
"""
881881
cmd = self._show_options_raw(
882-
_global=_global,
882+
global_=global_,
883883
scope=scope,
884884
include_hooks=include_hooks,
885885
include_inherited=include_inherited,
@@ -892,7 +892,7 @@ def _show_options_dict(
892892
def _show_options(
893893
self,
894894
g: bool | None = False,
895-
_global: bool | None = False,
895+
global_: bool | None = False,
896896
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
897897
include_hooks: bool | None = None,
898898
include_inherited: bool | None = None,
@@ -925,7 +925,7 @@ def _show_options(
925925
{...}
926926
"""
927927
dict_output = self._show_options_dict(
928-
_global=_global,
928+
global_=global_,
929929
scope=scope,
930930
include_hooks=include_hooks,
931931
include_inherited=include_inherited,
@@ -942,7 +942,7 @@ def _show_options(
942942
def _show_option_raw(
943943
self,
944944
option: str,
945-
_global: bool = False,
945+
global_: bool = False,
946946
g: bool = False,
947947
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
948948
ignore_errors: bool | None = None,
@@ -982,16 +982,16 @@ def _show_option_raw(
982982
>>> MyServer().cmd('new-session', '-d')
983983
<libtmux.common.tmux_cmd object at ...>
984984
985-
>>> MyServer()._show_option_raw('exit-unattached', _global=True)
985+
>>> MyServer()._show_option_raw('exit-unattached', global_=True)
986986
<libtmux.common.tmux_cmd object at ...>
987987
988-
>>> MyServer()._show_option_raw('exit-unattached', _global=True).stdout
988+
>>> MyServer()._show_option_raw('exit-unattached', global_=True).stdout
989989
['exit-unattached off']
990990
991-
>>> isinstance(MyServer()._show_option_raw('exit-unattached', _global=True).stdout, list)
991+
>>> isinstance(MyServer()._show_option_raw('exit-unattached', global_=True).stdout, list)
992992
True
993993
994-
>>> isinstance(MyServer()._show_option_raw('exit-unattached', _global=True).stdout[0], str)
994+
>>> isinstance(MyServer()._show_option_raw('exit-unattached', global_=True).stdout[0], str)
995995
True
996996
"""
997997
if scope is DEFAULT_OPTION_SCOPE:
@@ -1000,9 +1000,9 @@ def _show_option_raw(
10001000
flags: tuple[str | int, ...] = ()
10011001

10021002
if g:
1003-
warnings.warn("g argument is deprecated in favor of _global", stacklevel=2)
1003+
warnings.warn("g argument is deprecated in favor of global_", stacklevel=2)
10041004
flags += ("-g",)
1005-
elif _global:
1005+
elif global_:
10061006
flags += ("-g",)
10071007

10081008
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -1025,7 +1025,7 @@ def _show_option_raw(
10251025
def _show_option(
10261026
self,
10271027
option: str,
1028-
_global: bool = False,
1028+
global_: bool = False,
10291029
g: bool = False,
10301030
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
10311031
ignore_errors: bool | None = None,
@@ -1067,12 +1067,12 @@ def _show_option(
10671067
>>> MyServer().cmd('new-session', '-d')
10681068
<libtmux.common.tmux_cmd object at ...>
10691069
1070-
>>> MyServer()._show_option('exit-unattached', _global=True)
1070+
>>> MyServer()._show_option('exit-unattached', global_=True)
10711071
False
10721072
"""
10731073
cmd = self._show_option_raw(
10741074
option=option,
1075-
_global=_global,
1075+
global_=global_,
10761076
scope=scope,
10771077
ignore_errors=ignore_errors,
10781078
include_hooks=include_hooks,
@@ -1115,7 +1115,7 @@ def _show_option(
11151115
def show_option(
11161116
self,
11171117
option: str,
1118-
_global: bool = False,
1118+
global_: bool = False,
11191119
g: bool = False,
11201120
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
11211121
ignore_errors: bool | None = None,
@@ -1155,12 +1155,12 @@ def show_option(
11551155
>>> MyServer().cmd('new-session', '-d')
11561156
<libtmux.common.tmux_cmd object at ...>
11571157
1158-
>>> MyServer().show_option('exit-unattached', _global=True)
1158+
>>> MyServer().show_option('exit-unattached', global_=True)
11591159
False
11601160
"""
11611161
return self._show_option(
11621162
option=option,
1163-
_global=_global,
1163+
global_=global_,
11641164
scope=scope,
11651165
ignore_errors=ignore_errors,
11661166
include_hooks=include_hooks,

0 commit comments

Comments
 (0)