1313import typing as t
1414from 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
1823from . import exc
1924from ._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