File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -1172,12 +1172,12 @@ def allow_style_type(value: str) -> ru.AllowStyle:
11721172 @property
11731173 def allow_style (self ) -> ru .AllowStyle :
11741174 """Read-only property needed to support do_set when it reads allow_style."""
1175- return ru .allow_style
1175+ return ru .ALLOW_STYLE
11761176
11771177 @allow_style .setter
11781178 def allow_style (self , new_val : ru .AllowStyle ) -> None :
11791179 """Setter property needed to support do_set when it updates allow_style."""
1180- ru .allow_style = new_val
1180+ ru .ALLOW_STYLE = new_val
11811181
11821182 def _completion_supported (self ) -> bool :
11831183 """Return whether tab completion is supported."""
Original file line number Diff line number Diff line change 2828
2929
3030class AllowStyle (Enum ):
31- """Values for ``cmd2.rich_utils.allow_style ``."""
31+ """Values for ``cmd2.rich_utils.ALLOW_STYLE ``."""
3232
3333 ALWAYS = 'Always' # Always output ANSI style sequences
3434 NEVER = 'Never' # Remove ANSI style sequences from all output
@@ -44,7 +44,7 @@ def __repr__(self) -> str:
4444
4545
4646# Controls when ANSI style sequences are allowed in output
47- allow_style = AllowStyle .TERMINAL
47+ ALLOW_STYLE = AllowStyle .TERMINAL
4848
4949
5050class Cmd2Theme (Theme ):
@@ -123,13 +123,13 @@ def __init__(self, file: IO[str] | None = None) -> None:
123123 force_terminal : bool | None = None
124124 force_interactive : bool | None = None
125125
126- if allow_style == AllowStyle .ALWAYS :
126+ if ALLOW_STYLE == AllowStyle .ALWAYS :
127127 force_terminal = True
128128
129129 # Turn off interactive mode if dest is not actually a terminal which supports it
130130 tmp_console = Console (file = file )
131131 force_interactive = tmp_console .is_interactive
132- elif allow_style == AllowStyle .NEVER :
132+ elif ALLOW_STYLE == AllowStyle .NEVER :
133133 force_terminal = False
134134
135135 # Configure console defaults to treat output as plain, unstructured text.
Original file line number Diff line number Diff line change @@ -49,12 +49,12 @@ def arg_decorator(func):
4949
5050 @functools .wraps (func )
5151 def cmd_wrapper (* args , ** kwargs ):
52- old = ru .allow_style
53- ru .allow_style = style
52+ old = ru .ALLOW_STYLE
53+ ru .ALLOW_STYLE = style
5454 try :
5555 retval = func (* args , ** kwargs )
5656 finally :
57- ru .allow_style = old
57+ ru .ALLOW_STYLE = old
5858 return retval
5959
6060 return cmd_wrapper
@@ -244,20 +244,20 @@ def test_set_no_settables(base_app) -> None:
244244)
245245def test_set_allow_style (base_app , new_val , is_valid , expected ) -> None :
246246 # Initialize allow_style for this test
247- ru .allow_style = ru .AllowStyle .TERMINAL
247+ ru .ALLOW_STYLE = ru .AllowStyle .TERMINAL
248248
249249 # Use the set command to alter it
250250 out , err = run_cmd (base_app , f'set allow_style { new_val } ' )
251251 assert base_app .last_result is is_valid
252252
253253 # Verify the results
254- assert ru . allow_style == expected
254+ assert expected == ru . ALLOW_STYLE
255255 if is_valid :
256256 assert not err
257257 assert out
258258
259259 # Reset allow_style to its default since it's an application-wide setting that can affect other unit tests
260- ru .allow_style = ru .AllowStyle .TERMINAL
260+ ru .ALLOW_STYLE = ru .AllowStyle .TERMINAL
261261
262262
263263def test_set_with_choices (base_app ) -> None :
You can’t perform that action at this time.
0 commit comments