Skip to content

Commit f10fecf

Browse files
committed
!squash fix: rename _global to global_ in HooksMixin
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 in HooksMixin - Update docstring references to global_
1 parent 1f3727e commit f10fecf

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/libtmux/hooks.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def set_hook(
122122
ignore_errors: bool | None = None,
123123
append: bool | None = None,
124124
g: bool | None = None,
125-
_global: bool | None = None,
125+
global_: bool | None = None,
126126
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
127127
) -> Self:
128128
"""Set hook for tmux target.
@@ -170,8 +170,8 @@ def set_hook(
170170
assert isinstance(append, bool)
171171
flags.append("-a")
172172

173-
if _global is not None and _global:
174-
assert isinstance(_global, bool)
173+
if global_ is not None and global_:
174+
assert isinstance(global_, bool)
175175
flags.append("-g")
176176

177177
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -201,7 +201,7 @@ def set_hook(
201201
def unset_hook(
202202
self,
203203
hook: str,
204-
_global: bool | None = None,
204+
global_: bool | None = None,
205205
ignore_errors: bool | None = None,
206206
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
207207
) -> Self:
@@ -228,8 +228,8 @@ def unset_hook(
228228
assert isinstance(ignore_errors, bool)
229229
flags.append("-q")
230230

231-
if _global is not None and _global:
232-
assert isinstance(_global, bool)
231+
if global_ is not None and global_:
232+
assert isinstance(global_, bool)
233233
flags.append("-g")
234234

235235
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -257,7 +257,7 @@ def unset_hook(
257257

258258
def show_hooks(
259259
self,
260-
_global: bool | None = False,
260+
global_: bool | None = False,
261261
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
262262
ignore_errors: bool | None = None,
263263
) -> HookDict:
@@ -267,7 +267,7 @@ def show_hooks(
267267

268268
flags: tuple[str, ...] = ()
269269

270-
if _global:
270+
if global_:
271271
flags += ("-g",)
272272

273273
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -306,7 +306,7 @@ def show_hooks(
306306
def _show_hook(
307307
self,
308308
hook: str,
309-
_global: bool = False,
309+
global_: bool = False,
310310
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
311311
ignore_errors: bool | None = None,
312312
) -> list[str] | None:
@@ -326,7 +326,7 @@ def _show_hook(
326326

327327
flags: tuple[str | int, ...] = ()
328328

329-
if _global:
329+
if global_:
330330
flags += ("-g",)
331331

332332
if scope is not None and not isinstance(scope, _DefaultOptionScope):
@@ -356,7 +356,7 @@ def _show_hook(
356356
def show_hook(
357357
self,
358358
hook: str,
359-
_global: bool = False,
359+
global_: bool = False,
360360
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
361361
ignore_errors: bool | None = None,
362362
) -> str | int | None:
@@ -386,7 +386,7 @@ def show_hook(
386386
def get_hook_indices(
387387
self,
388388
hook: str,
389-
_global: bool = False,
389+
global_: bool = False,
390390
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
391391
ignore_errors: bool | None = None,
392392
) -> list[int]:
@@ -396,7 +396,7 @@ def get_hook_indices(
396396
----------
397397
hook : str
398398
Hook name, e.g. 'session-renamed'
399-
_global : bool
399+
global_ : bool
400400
Use global hooks
401401
scope : OptionScope | None
402402
Scope for the hook
@@ -424,7 +424,7 @@ def get_hook_indices(
424424
"""
425425
hooks_output = self._show_hook(
426426
hook=hook,
427-
_global=_global,
427+
global_=global_,
428428
scope=scope,
429429
ignore_errors=ignore_errors,
430430
)
@@ -439,7 +439,7 @@ def get_hook_indices(
439439
def get_hook_values(
440440
self,
441441
hook: str,
442-
_global: bool = False,
442+
global_: bool = False,
443443
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
444444
ignore_errors: bool | None = None,
445445
) -> SparseArray[str]:
@@ -449,7 +449,7 @@ def get_hook_values(
449449
----------
450450
hook : str
451451
Hook name, e.g. 'session-renamed'
452-
_global : bool
452+
global_ : bool
453453
Use global hooks
454454
scope : OptionScope | None
455455
Scope for the hook
@@ -478,7 +478,7 @@ def get_hook_values(
478478
"""
479479
hooks_output = self._show_hook(
480480
hook=hook,
481-
_global=_global,
481+
global_=global_,
482482
scope=scope,
483483
ignore_errors=ignore_errors,
484484
)
@@ -498,7 +498,7 @@ def set_hooks_bulk(
498498
values: HookValues,
499499
*,
500500
clear_existing: bool = False,
501-
_global: bool | None = None,
501+
global_: bool | None = None,
502502
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
503503
) -> Self:
504504
"""Set multiple indexed hooks at once.
@@ -514,7 +514,7 @@ def set_hooks_bulk(
514514
- list[str]: ['cmd1', 'cmd2'] - sequential indices starting at 0
515515
clear_existing : bool
516516
If True, unset all existing hook values first
517-
_global : bool | None
517+
global_ : bool | None
518518
Use global hooks
519519
scope : OptionScope | None
520520
Scope for the hook
@@ -564,7 +564,7 @@ def set_hooks_bulk(
564564
Session($...)
565565
"""
566566
if clear_existing:
567-
self.clear_hook(hook, _global=_global, scope=scope)
567+
self.clear_hook(hook, global_=global_, scope=scope)
568568

569569
# Convert list to dict with sequential indices
570570
if isinstance(values, list):
@@ -574,7 +574,7 @@ def set_hooks_bulk(
574574
self.set_hook(
575575
f"{hook}[{index}]",
576576
value,
577-
_global=_global,
577+
global_=global_,
578578
scope=scope,
579579
)
580580

@@ -583,7 +583,7 @@ def set_hooks_bulk(
583583
def clear_hook(
584584
self,
585585
hook: str,
586-
_global: bool | None = None,
586+
global_: bool | None = None,
587587
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
588588
ignore_errors: bool | None = None,
589589
) -> Self:
@@ -593,7 +593,7 @@ def clear_hook(
593593
----------
594594
hook : str
595595
Hook name, e.g. 'session-renamed'
596-
_global : bool | None
596+
global_ : bool | None
597597
Use global hooks
598598
scope : OptionScope | None
599599
Scope for the hook
@@ -624,14 +624,14 @@ def clear_hook(
624624
"""
625625
indices = self.get_hook_indices(
626626
hook,
627-
_global=_global if _global is not None else False,
627+
global_=global_ if global_ is not None else False,
628628
scope=scope,
629629
ignore_errors=ignore_errors,
630630
)
631631
for index in indices:
632632
self.unset_hook(
633633
f"{hook}[{index}]",
634-
_global=_global,
634+
global_=global_,
635635
scope=scope,
636636
ignore_errors=ignore_errors,
637637
)
@@ -641,7 +641,7 @@ def append_hook(
641641
self,
642642
hook: str,
643643
value: str,
644-
_global: bool | None = None,
644+
global_: bool | None = None,
645645
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
646646
) -> Self:
647647
"""Append a hook value at the next available index.
@@ -652,7 +652,7 @@ def append_hook(
652652
Hook name, e.g. 'session-renamed'
653653
value : str
654654
Hook command to append
655-
_global : bool | None
655+
global_ : bool | None
656656
Use global hooks
657657
scope : OptionScope | None
658658
Scope for the hook
@@ -678,14 +678,14 @@ def append_hook(
678678
"""
679679
indices = self.get_hook_indices(
680680
hook,
681-
_global=_global if _global is not None else False,
681+
global_=global_ if global_ is not None else False,
682682
scope=scope,
683683
)
684684
next_index = max(indices) + 1 if indices else 0
685685
self.set_hook(
686686
f"{hook}[{next_index}]",
687687
value,
688-
_global=_global,
688+
global_=global_,
689689
scope=scope,
690690
)
691691
return self

0 commit comments

Comments
 (0)