Skip to content

Commit d00f5d3

Browse files
committed
common: _DefaultScope sentinel value
1 parent 6b85623 commit d00f5d3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/libtmux/common.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
import typing as t
1414
from typing import Dict, Optional, Union
1515

16-
from libtmux.constants import OPTION_SCOPE_FLAG_MAP, OptionScope
16+
from libtmux.constants import (
17+
DEFAULT_SCOPE,
18+
OPTION_SCOPE_FLAG_MAP,
19+
OptionScope,
20+
_DefaultScope,
21+
)
1722

1823
from . import exc
1924
from ._compat import LooseVersion, console_to_str, str_from_console
@@ -71,7 +76,7 @@ def set_option(
7176
suppress_warnings: t.Optional[bool] = None,
7277
append: t.Optional[bool] = None,
7378
g: t.Optional[bool] = None,
74-
scope: t.Optional[OptionScope] = None,
79+
scope: t.Optional[t.Union[OptionScope, _DefaultScope]] = None,
7580
) -> "t.Self":
7681
"""Set option for tmux window.
7782
@@ -90,6 +95,9 @@ def set_option(
9095
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
9196
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
9297
"""
98+
if scope is DEFAULT_SCOPE:
99+
scope = self.default_scope
100+
93101
flags: t.List[str] = []
94102
if isinstance(value, bool) and value:
95103
value = "on"
@@ -124,7 +132,7 @@ def set_option(
124132
assert isinstance(g, bool)
125133
flags.append("-g")
126134

127-
if scope is not None:
135+
if scope is not None and not isinstance(scope, _DefaultScope):
128136
assert scope in OPTION_SCOPE_FLAG_MAP
129137
flags.append(
130138
OPTION_SCOPE_FLAG_MAP[scope],

0 commit comments

Comments
 (0)