From adabfb53e7070807b6305d0602fbf52a6242c88a Mon Sep 17 00:00:00 2001 From: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:43:44 +0100 Subject: [PATCH] fix glob no magic (#2056) --- src/huggingface_hub/hf_file_system.py | 2 +- tests/test_hf_file_system.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/huggingface_hub/hf_file_system.py b/src/huggingface_hub/hf_file_system.py index 08761eb528..b277cb5ea4 100644 --- a/src/huggingface_hub/hf_file_system.py +++ b/src/huggingface_hub/hf_file_system.py @@ -557,7 +557,7 @@ def info(self, path: str, refresh: bool = False, revision: Optional[str] = None, def exists(self, path, **kwargs): """Is there a file at the given path""" try: - self.info(path, expand_info=False, **kwargs) + self.info(path, **{**kwargs, "expand_info": False}) return True except: # noqa: E722 # any exception allowed bar FileNotFoundError? diff --git a/tests/test_hf_file_system.py b/tests/test_hf_file_system.py index af9bf3b94f..e2b7e8413c 100644 --- a/tests/test_hf_file_system.py +++ b/tests/test_hf_file_system.py @@ -81,6 +81,10 @@ def test_info(self): self.assertEqual(self.hffs.info(self.hf_path + "/data/text_data.txt"), text_data_file) def test_glob(self): + self.assertEqual( + self.hffs.glob(self.hf_path + "/.gitattributes"), + [self.hf_path + "/.gitattributes"], + ) self.assertEqual( sorted(self.hffs.glob(self.hf_path + "/*")), sorted([self.hf_path + "/.gitattributes", self.hf_path + "/data"]),