Skip to content

Commit e2e328b

Browse files
committed
Fix formatting style
1 parent e070c15 commit e2e328b

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/sagemaker/_studio.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ def _find_config(working_dir=None):
6565
wd = Path(working_dir) if working_dir else Path.cwd()
6666

6767
path = None
68-
69-
root = Path(wd.anchor) # Properly get the root of the current working directory for both Windows and Unix-like systems
68+
69+
root = Path(
70+
wd.anchor
71+
) # Properly get the root of the current working directory for both Windows and Unix-like systems
7072
while path is None and wd != root:
7173
candidate = wd / STUDIO_PROJECT_CONFIG
7274
if Path.exists(candidate):

tests/unit/sagemaker/test_studio.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,44 @@
2121
_parse_tags,
2222
)
2323

24+
2425
def test_find_config_cross_platform(tmpdir):
2526
"""Test _find_config works correctly across different platforms."""
2627
# Create a completely separate directory for isolated tests
2728
import tempfile
29+
2830
with tempfile.TemporaryDirectory() as isolated_root:
2931
# Setup test directory structure for positive tests
3032
config = tmpdir.join(".sagemaker-code-config")
3133
config.write('{"sagemakerProjectId": "proj-1234"}')
32-
34+
3335
# Test 1: Direct parent directory
3436
working_dir = tmpdir.mkdir("sub")
3537
found_path = _find_config(working_dir)
3638
assert found_path == config
37-
39+
3840
# Test 2: Deeply nested directories
3941
nested_dir = tmpdir.mkdir("deep").mkdir("nested").mkdir("path")
4042
found_path = _find_config(nested_dir)
4143
assert found_path == config
42-
44+
4345
# Test 3: Start from root directory
4446
import os
47+
4548
root_dir = os.path.abspath(os.sep)
4649
found_path = _find_config(root_dir)
4750
assert found_path is None
48-
51+
4952
# Test 4: No config file in path - using truly isolated directory
5053
isolated_path = Path(isolated_root) / "nested" / "path"
5154
isolated_path.mkdir(parents=True)
5255
found_path = _find_config(isolated_path)
5356
assert found_path is None
5457

58+
5559
def test_find_config_path_separators(tmpdir):
5660
"""Test _find_config handles different path separator styles.
57-
61+
5862
Tests:
5963
1. Forward slashes
6064
2. Backslashes
@@ -64,20 +68,21 @@ def test_find_config_path_separators(tmpdir):
6468
config = tmpdir.join(".sagemaker-code-config")
6569
config.write('{"sagemakerProjectId": "proj-1234"}')
6670
base_path = str(tmpdir)
67-
71+
6872
# Test different path separator styles
6973
paths = [
7074
os.path.join(base_path, "dir1", "dir2"), # OS native
71-
"/".join([base_path, "dir1", "dir2"]), # Forward slashes
72-
"\\".join([base_path, "dir1", "dir2"]), # Backslashes
73-
base_path + "/dir1\\dir2" # Mixed
75+
"/".join([base_path, "dir1", "dir2"]), # Forward slashes
76+
"\\".join([base_path, "dir1", "dir2"]), # Backslashes
77+
base_path + "/dir1\\dir2", # Mixed
7478
]
75-
79+
7680
for path in paths:
7781
os.makedirs(path, exist_ok=True)
7882
found_path = _find_config(path)
7983
assert found_path == config
8084

85+
8186
def test_find_config(tmpdir):
8287
path = tmpdir.join(".sagemaker-code-config")
8388
path.write('{"sagemakerProjectId": "proj-1234"}')

0 commit comments

Comments
 (0)