Skip to content

Commit f96cfec

Browse files
committed
Revert "Fix Windows path separator issue in paired notebooks (#1454)"
This reverts commit 3b47cde but keeps the added test
1 parent 3b47cde commit f96cfec

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/jupytext/paired_paths.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,7 @@ def join(left, right, sep):
6161

6262
def separator(path):
6363
"""Return the local path separator (always / in the contents manager)"""
64-
# On Windows, determine the appropriate separator
65-
if os.path.sep == "\\":
66-
# If path contains \, definitely use Windows separator
67-
if "\\" in path:
68-
return "\\"
69-
# If path contains / but not \, it's probably a format string or contents manager path
70-
if "/" in path:
71-
return "/"
72-
# Path has no separators (e.g., bare filename) - use OS separator
64+
if os.path.sep == "\\" and "\\" in path:
7365
return "\\"
7466
return "/"
7567

tests/unit/test_paired_paths.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_paired_paths_windows_no_subfolder():
101101

102102
def test_paired_paths_windows_relative():
103103
"""Test Windows pairing with relative paths and backslash as path separator, issue #1028"""
104-
nb_file = "notebooks\\example.ipynb"
104+
nb_file = "C:\\notebooks\\example.ipynb"
105105
formats = "notebooks///ipynb,scripts///py:percent"
106106
with mock.patch("os.path.sep", "\\"):
107107
# Should not raise InconsistentPath
@@ -110,8 +110,8 @@ def test_paired_paths_windows_relative():
110110
path_list = [p[0] for p in paths]
111111
assert nb_file in path_list, f"Expected {nb_file} to be in paired paths {path_list}"
112112
# Verify both paths use backslashes on Windows
113-
assert paths[0][0] == "notebooks\\example.ipynb"
114-
assert paths[1][0] == "scripts\\example.py"
113+
assert paths[0][0] == "C:\\notebooks\\example.ipynb"
114+
assert paths[1][0] == "C:\\scripts\\example.py"
115115

116116

117117
@pytest.mark.parametrize("os_path_sep", ["\\", "/"])

0 commit comments

Comments
 (0)