From b3db52d47ed87f79e51ead34ab3680135372e55a Mon Sep 17 00:00:00 2001 From: itzzdev09 Date: Mon, 14 Sep 2026 23:29:08 +0530 Subject: [PATCH] Treat huggingface_hub's single-segment repo id ValueError as unsupported in HfPath.iterdir Newer huggingface_hub releases raise ValueError instead of NotImplementedError when asked to list a namespace such as a user's repositories, which made test_iterdir_parent_iteration fail. Fixes #562 Co-Authored-By: Claude Opus 5 --- upath/implementations/cloud.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upath/implementations/cloud.py b/upath/implementations/cloud.py index 0f76b4c1..984fd97c 100644 --- a/upath/implementations/cloud.py +++ b/upath/implementations/cloud.py @@ -216,7 +216,10 @@ def root(self) -> str: def iterdir(self) -> Iterator[Self]: try: yield from super().iterdir() - except NotImplementedError: + except (NotImplementedError, ValueError): + # listing a namespace (e.g. a user's repositories) is unsupported: + # older huggingface_hub raises NotImplementedError, newer versions + # reject the single-segment repository id with a ValueError raise UnsupportedOperation def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None: