Skip to content

Commit eca6c70

Browse files
author
Roja Reddy Sareddy
committed
style(core): apply black to rich-logging changes
Reformat test_rich_logging.py (blank line after docstring, parenthesized context managers) and collapse a one-line return in utils.py to satisfy black --check in the codestyle-doc-tests CI job.
1 parent 1299434 commit eca6c70

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎sagemaker-core/src/sagemaker/core/utils/utils.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ def is_rich_logging_enabled() -> bool:
154154
Returns:
155155
bool: True if rich console/traceback output has been opted into.
156156
"""
157-
return (
158-
os.environ.get(RICH_LOGGING_OPT_IN_ENV_VAR, "").strip().lower() in _TRUTHY_ENV_VALUES
159-
)
157+
return os.environ.get(RICH_LOGGING_OPT_IN_ENV_VAR, "").strip().lower() in _TRUTHY_ENV_VALUES
160158

161159

162160
textual_rich_console_and_traceback_enabled = False

‎sagemaker-core/tests/unit/utils/test_rich_logging.py‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
process-global rich console unless the user explicitly opts in via
55
SAGEMAKER_ENABLE_RICH_LOGGING (or a force=True call).
66
"""
7+
78
import os
89
from unittest.mock import patch
910

@@ -45,9 +46,10 @@ def test_disabled_by_default_is_noop():
4546
# or install rich tracebacks (no sys.excepthook override).
4647
with patch.dict(os.environ, {}, clear=False):
4748
os.environ.pop(RICH_LOGGING_OPT_IN_ENV_VAR, None)
48-
with patch.object(utils, "reconfigure") as mock_reconfigure, patch.object(
49-
utils, "install"
50-
) as mock_install:
49+
with (
50+
patch.object(utils, "reconfigure") as mock_reconfigure,
51+
patch.object(utils, "install") as mock_install,
52+
):
5153
enable_textual_rich_console_and_traceback()
5254
mock_reconfigure.assert_not_called()
5355
mock_install.assert_not_called()
@@ -56,9 +58,10 @@ def test_disabled_by_default_is_noop():
5658

5759
def test_enabled_when_opted_in_via_env():
5860
with patch.dict(os.environ, {RICH_LOGGING_OPT_IN_ENV_VAR: "true"}):
59-
with patch.object(utils, "reconfigure") as mock_reconfigure, patch.object(
60-
utils, "install"
61-
) as mock_install:
61+
with (
62+
patch.object(utils, "reconfigure") as mock_reconfigure,
63+
patch.object(utils, "install") as mock_install,
64+
):
6265
enable_textual_rich_console_and_traceback()
6366
mock_reconfigure.assert_called_once()
6467
mock_install.assert_called_once()
@@ -68,19 +71,21 @@ def test_enabled_when_opted_in_via_env():
6871
def test_force_enables_regardless_of_env():
6972
with patch.dict(os.environ, {}, clear=False):
7073
os.environ.pop(RICH_LOGGING_OPT_IN_ENV_VAR, None)
71-
with patch.object(utils, "reconfigure") as mock_reconfigure, patch.object(
72-
utils, "install"
73-
) as mock_install:
74+
with (
75+
patch.object(utils, "reconfigure") as mock_reconfigure,
76+
patch.object(utils, "install") as mock_install,
77+
):
7478
enable_textual_rich_console_and_traceback(force=True)
7579
mock_reconfigure.assert_called_once()
7680
mock_install.assert_called_once()
7781

7882

7983
def test_enable_is_idempotent_when_opted_in():
8084
with patch.dict(os.environ, {RICH_LOGGING_OPT_IN_ENV_VAR: "1"}):
81-
with patch.object(utils, "reconfigure") as mock_reconfigure, patch.object(
82-
utils, "install"
83-
) as mock_install:
85+
with (
86+
patch.object(utils, "reconfigure") as mock_reconfigure,
87+
patch.object(utils, "install") as mock_install,
88+
):
8489
enable_textual_rich_console_and_traceback()
8590
enable_textual_rich_console_and_traceback()
8691
# The one-shot latch prevents re-installing on the second call.

0 commit comments

Comments
 (0)