From b25acc1660ab72f5d9f37ed37cbbd17563caa911 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Mon, 21 Aug 2023 14:47:00 +0200 Subject: [PATCH] Use os.sep as a pre-replacer --- ci_cd/tasks/api_reference_docs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci_cd/tasks/api_reference_docs.py b/ci_cd/tasks/api_reference_docs.py index fbe1aa9c..971f71f4 100644 --- a/ci_cd/tasks/api_reference_docs.py +++ b/ci_cd/tasks/api_reference_docs.py @@ -301,8 +301,9 @@ def write_file(full_path: Path, content: str) -> None: else f"{py_path_root}/{relpath if single_package else relpath.relative_to(package.name)}/{filename.stem}" ) - # Cast py_path to Path to ensure correct formatting (forward slashes) - py_path = str(Path(py_path)).replace("/", ".") + # Replace OS specific path separators with forward slashes before + # replacing that with dots (for Python import paths). + py_path = py_path.replace(os.sep, "/").replace("/", ".") LOGGER.debug("filename: %s\npy_path: %s", filename, py_path) if debug: