From dd18be7b00a0b4d0795667d2ad70235c223ae250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C5=A9=20Thanh=20H=C3=A0?= Date: Thu, 12 Oct 2023 19:06:05 +0700 Subject: [PATCH] Fix UnboundLocalError when using commit context manager (#1722) --- src/huggingface_hub/repository.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/huggingface_hub/repository.py b/src/huggingface_hub/repository.py index d13b287aac..cfd722c324 100644 --- a/src/huggingface_hub/repository.py +++ b/src/huggingface_hub/repository.py @@ -1367,9 +1367,7 @@ def commit( files_to_stage = files_to_be_staged(".", folder=self.local_dir) if len(files_to_stage): - if len(files_to_stage) > 5: - files_in_msg = str(files_to_stage[:5])[:-1] + ", ...]" - + files_in_msg = str(files_to_stage[:5])[:-1] + ", ...]" if len(files_to_stage) > 5 else str(files_to_stage) logger.error( "There exists some updated files in the local repository that are not" f" committed: {files_in_msg}. This may lead to errors if checking out"