From 69b3391994a91d2d582a4a7e303d42a8cba3e972 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Fri, 26 Jan 2024 19:44:54 +0100 Subject: [PATCH] upath.implementations.memory: normalize to two slashes for py312 --- upath/implementations/memory.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/upath/implementations/memory.py b/upath/implementations/memory.py index 3dfa0b3..cd22b4c 100644 --- a/upath/implementations/memory.py +++ b/upath/implementations/memory.py @@ -71,3 +71,17 @@ def iterdir(self): def path(self): path = super().path return "/" if path == "." else path + + @classmethod + def _format_parsed_parts( + cls, + drv: str, + root: str, + parts: list[str], + url: SplitResult | None = None, + **kwargs: Any, + ) -> str: + s = super()._format_parsed_parts(drv, root, parts, url=url, **kwargs) + if s.startswith("memory:///"): + s = s.replace("memory:///", "memory://", 1) + return s