Skip to content

Commit 09ca652

Browse files
committed
!squash common
1 parent 7cf245c commit 09ca652

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/libtmux/common.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def set_option(
7777
suppress_warnings: t.Optional[bool] = None,
7878
append: t.Optional[bool] = None,
7979
g: t.Optional[bool] = None,
80-
scope: t.Optional[t.Union[OptionScope, _DefaultScope]] = None,
80+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]] = DEFAULT_SCOPE,
8181
) -> "t.Self":
8282
"""Set option for tmux window.
8383
@@ -155,7 +155,7 @@ def set_option(
155155
def show_options(
156156
self,
157157
g: t.Optional[bool],
158-
scope: t.Optional[OptionScope],
158+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]],
159159
include_hooks: t.Optional[bool],
160160
include_parents: t.Optional[bool],
161161
values_only: t.Literal[True],
@@ -166,7 +166,7 @@ def show_options(
166166
def show_options(
167167
self,
168168
g: t.Optional[bool],
169-
scope: t.Optional[OptionScope],
169+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]],
170170
include_hooks: t.Optional[bool],
171171
include_parents: t.Optional[bool],
172172
values_only: t.Literal[None] = None,
@@ -177,7 +177,7 @@ def show_options(
177177
def show_options(
178178
self,
179179
g: t.Optional[bool] = None,
180-
scope: t.Optional[OptionScope] = None,
180+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]] = DEFAULT_SCOPE,
181181
include_hooks: t.Optional[bool] = None,
182182
include_parents: t.Optional[bool] = None,
183183
values_only: t.Literal[False] = False,
@@ -187,7 +187,7 @@ def show_options(
187187
def show_options(
188188
self,
189189
g: t.Optional[bool] = False,
190-
scope: t.Optional[OptionScope] = OptionScope.Window,
190+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]] = DEFAULT_SCOPE,
191191
include_hooks: t.Optional[bool] = None,
192192
include_parents: t.Optional[bool] = None,
193193
values_only: t.Optional[bool] = False,
@@ -199,12 +199,15 @@ def show_options(
199199
g : str, optional
200200
Pass ``-g`` flag for global variable, default False.
201201
"""
202+
if scope is DEFAULT_SCOPE:
203+
scope = self.default_scope
204+
202205
tmux_args: t.Tuple[str, ...] = ()
203206

204207
if g:
205208
tmux_args += ("-g",)
206209

207-
if scope is not None:
210+
if scope is not None and not isinstance(scope, _DefaultScope):
208211
assert scope in OPTION_SCOPE_FLAG_MAP
209212
tmux_args += (OPTION_SCOPE_FLAG_MAP[scope],)
210213

@@ -243,7 +246,7 @@ def show_option(
243246
self,
244247
option: str,
245248
g: bool = False,
246-
scope: t.Optional[OptionScope] = OptionScope.Window,
249+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]] = DEFAULT_SCOPE,
247250
include_hooks: t.Optional[bool] = None,
248251
include_parents: t.Optional[bool] = None,
249252
) -> t.Optional[t.Union[str, int]]:
@@ -262,12 +265,15 @@ def show_option(
262265
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
263266
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
264267
"""
268+
if scope is DEFAULT_SCOPE:
269+
scope = self.default_scope
270+
265271
tmux_args: t.Tuple[t.Union[str, int], ...] = ()
266272

267273
if g:
268274
tmux_args += ("-g",)
269275

270-
if scope is not None:
276+
if scope is not None and not isinstance(scope, _DefaultScope):
271277
assert scope in OPTION_SCOPE_FLAG_MAP
272278
tmux_args += (OPTION_SCOPE_FLAG_MAP[scope],)
273279

0 commit comments

Comments
 (0)