13
13
import typing as t
14
14
from typing import Dict , Optional , Union
15
15
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
+ )
17
22
18
23
from . import exc
19
24
from ._compat import LooseVersion , console_to_str , str_from_console
@@ -71,7 +76,7 @@ def set_option(
71
76
suppress_warnings : t .Optional [bool ] = None ,
72
77
append : t .Optional [bool ] = None ,
73
78
g : t .Optional [bool ] = None ,
74
- scope : t .Optional [OptionScope ] = None ,
79
+ scope : t .Optional [t . Union [ OptionScope , _DefaultScope ] ] = None ,
75
80
) -> "t.Self" :
76
81
"""Set option for tmux window.
77
82
@@ -90,6 +95,9 @@ def set_option(
90
95
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
91
96
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
92
97
"""
98
+ if scope is DEFAULT_SCOPE :
99
+ scope = self .default_scope
100
+
93
101
flags : t .List [str ] = []
94
102
if isinstance (value , bool ) and value :
95
103
value = "on"
@@ -124,7 +132,7 @@ def set_option(
124
132
assert isinstance (g , bool )
125
133
flags .append ("-g" )
126
134
127
- if scope is not None :
135
+ if scope is not None and not isinstance ( scope , _DefaultScope ) :
128
136
assert scope in OPTION_SCOPE_FLAG_MAP
129
137
flags .append (
130
138
OPTION_SCOPE_FLAG_MAP [scope ],
0 commit comments