From e31f75c1c6d8db59abe9ebc825b5605cba55cb74 Mon Sep 17 00:00:00 2001 From: Hayden Andreyka Date: Thu, 13 Jun 2024 17:18:02 -0700 Subject: [PATCH 1/3] fix: python complaining about backslashes inside f-string expressions refactor excessively long f-string into separate variables --- tagstudio/src/qt/modals/drop_import.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tagstudio/src/qt/modals/drop_import.py b/tagstudio/src/qt/modals/drop_import.py index 2796a81aa..ae6daa17e 100644 --- a/tagstudio/src/qt/modals/drop_import.py +++ b/tagstudio/src/qt/modals/drop_import.py @@ -167,10 +167,11 @@ def duplicates_choice(self) -> int: dupes_to_show = self.duplicate_files if len(self.duplicate_files) > display_limit: dupes_to_show = dupes_to_show[0:display_limit] + + dupes_str = '\n '.join(map(lambda path: str(path),dupes_to_show)) + dupes_more = "\nand {len(self.duplicate_files)-display_limit} more " if len(self.duplicate_files) > display_limit else '\n' - msgBox.setText( - f"The following files:\n {'\n '.join(map(lambda path: str(path),self.get_relative_paths(dupes_to_show)))} {(f'\nand {len(self.duplicate_files)-display_limit} more ') if len(self.duplicate_files)>display_limit else '\n'}have filenames that already exist in the library folder." - ) + msgBox.setText(f"The following files:\n {dupes_str}{dupes_more}have filenames that already exist in the library folder.") msgBox.addButton("Skip", QMessageBox.ButtonRole.YesRole) msgBox.addButton("Override", QMessageBox.ButtonRole.DestructiveRole) msgBox.addButton("Rename", QMessageBox.ButtonRole.DestructiveRole) From ec1376168a3751b9d5a32b666082649c8edf2abd Mon Sep 17 00:00:00 2001 From: Hayden Andreyka Date: Thu, 13 Jun 2024 18:15:55 -0700 Subject: [PATCH 2/3] fix: missing f on f-string --- tagstudio/src/qt/modals/drop_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tagstudio/src/qt/modals/drop_import.py b/tagstudio/src/qt/modals/drop_import.py index ae6daa17e..855801353 100644 --- a/tagstudio/src/qt/modals/drop_import.py +++ b/tagstudio/src/qt/modals/drop_import.py @@ -169,7 +169,7 @@ def duplicates_choice(self) -> int: dupes_to_show = dupes_to_show[0:display_limit] dupes_str = '\n '.join(map(lambda path: str(path),dupes_to_show)) - dupes_more = "\nand {len(self.duplicate_files)-display_limit} more " if len(self.duplicate_files) > display_limit else '\n' + dupes_more = f"\nand {len(self.duplicate_files)-display_limit} more " if len(self.duplicate_files) > display_limit else '\n' msgBox.setText(f"The following files:\n {dupes_str}{dupes_more}have filenames that already exist in the library folder.") msgBox.addButton("Skip", QMessageBox.ButtonRole.YesRole) From 030dfc79c0eae61a4e3d77e7c16bc80f54a0559a Mon Sep 17 00:00:00 2001 From: Travis Abendshien Date: Thu, 13 Jun 2024 18:33:08 -0700 Subject: [PATCH 3/3] Format with Ruff --- tagstudio/src/qt/modals/drop_import.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tagstudio/src/qt/modals/drop_import.py b/tagstudio/src/qt/modals/drop_import.py index 855801353..370694e32 100644 --- a/tagstudio/src/qt/modals/drop_import.py +++ b/tagstudio/src/qt/modals/drop_import.py @@ -167,11 +167,17 @@ def duplicates_choice(self) -> int: dupes_to_show = self.duplicate_files if len(self.duplicate_files) > display_limit: dupes_to_show = dupes_to_show[0:display_limit] - - dupes_str = '\n '.join(map(lambda path: str(path),dupes_to_show)) - dupes_more = f"\nand {len(self.duplicate_files)-display_limit} more " if len(self.duplicate_files) > display_limit else '\n' - msgBox.setText(f"The following files:\n {dupes_str}{dupes_more}have filenames that already exist in the library folder.") + dupes_str = "\n ".join(map(lambda path: str(path), dupes_to_show)) + dupes_more = ( + f"\nand {len(self.duplicate_files)-display_limit} more " + if len(self.duplicate_files) > display_limit + else "\n" + ) + + msgBox.setText( + f"The following files:\n {dupes_str}{dupes_more}have filenames that already exist in the library folder." + ) msgBox.addButton("Skip", QMessageBox.ButtonRole.YesRole) msgBox.addButton("Override", QMessageBox.ButtonRole.DestructiveRole) msgBox.addButton("Rename", QMessageBox.ButtonRole.DestructiveRole)