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: