Skip to content

Commit 90757c9

Browse files
committed
OptionsMixin(fix): Use DeprecationWarning for deprecated g parameter
why: Deprecation warnings should use proper DeprecationWarning category to be properly filtered by Python's warning system what: - Update all 4 instances of g deprecation warning to use category=DeprecationWarning - Affects set_option, _show_options_raw, _show_option_raw, show_option
1 parent 17c4ccd commit 90757c9

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/libtmux/options.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,11 @@ 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(
671+
"g argument is deprecated in favor of global_",
672+
category=DeprecationWarning,
673+
stacklevel=2,
674+
)
671675
global_ = g
672676

673677
if global_ is not None and global_:
@@ -823,7 +827,11 @@ def _show_options_raw(
823827
flags: tuple[str, ...] = ()
824828

825829
if g:
826-
warnings.warn("g argument is deprecated in favor of global_", stacklevel=2)
830+
warnings.warn(
831+
"g argument is deprecated in favor of global_",
832+
category=DeprecationWarning,
833+
stacklevel=2,
834+
)
827835
flags += ("-g",)
828836
elif global_:
829837
flags += ("-g",)
@@ -1048,7 +1056,11 @@ def _show_option_raw(
10481056
flags: tuple[str | int, ...] = ()
10491057

10501058
if g:
1051-
warnings.warn("g argument is deprecated in favor of global_", stacklevel=2)
1059+
warnings.warn(
1060+
"g argument is deprecated in favor of global_",
1061+
category=DeprecationWarning,
1062+
stacklevel=2,
1063+
)
10521064
flags += ("-g",)
10531065
elif global_:
10541066
flags += ("-g",)
@@ -1209,7 +1221,11 @@ def show_option(
12091221
False
12101222
"""
12111223
if g:
1212-
warnings.warn("g argument is deprecated in favor of global_", stacklevel=2)
1224+
warnings.warn(
1225+
"g argument is deprecated in favor of global_",
1226+
category=DeprecationWarning,
1227+
stacklevel=2,
1228+
)
12131229
global_ = g
12141230

12151231
return self._show_option(

0 commit comments

Comments
 (0)