From e452fa153b2a819b3afda60e095548d2bae12239 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sat, 22 Jun 2024 20:21:01 -0700 Subject: [PATCH] Fix issues from static analysis --- comicapi/tags/comicrack.py | 8 ++------ comictaggerlib/cli.py | 7 ++----- comictaggerlib/coverimagewidget.py | 3 ++- comictaggerlib/ctsettings/commandline.py | 4 ++-- comictaggerlib/main.py | 2 +- comictaggerlib/taggerwindow.py | 3 +-- comictaggerlib/ui/talkeruigenerator.py | 2 -- comictalker/comiccacher.py | 2 -- 8 files changed, 10 insertions(+), 21 deletions(-) diff --git a/comicapi/tags/comicrack.py b/comicapi/tags/comicrack.py index 569e4e0..eb11422 100644 --- a/comicapi/tags/comicrack.py +++ b/comicapi/tags/comicrack.py @@ -157,13 +157,9 @@ class ComicRack(Tag): def assign(cr_entry: str, md_entry: Any) -> None: if md_entry: - text = "" - if isinstance(md_entry, str): - text = md_entry - elif isinstance(md_entry, (list, set)): + text = str(md_entry) + if isinstance(md_entry, (list, set)): text = ",".join(md_entry) - else: - text = str(md_entry) et_entry = root.find(cr_entry) if et_entry is not None: et_entry.text = text diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index cab4fae..474a0d1 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -470,10 +470,6 @@ class CLI: ii = IssueIdentifier(ca, self.config, self.current_talker()) - def myoutput(text: str) -> None: - if self.config.Runtime_Options__verbose: - self.output(text) - ii.set_output_function(functools.partial(self.output, already_logged=True)) if not self.config.Auto_Tag__use_year_when_identifying: md.year = None @@ -679,7 +675,8 @@ class CLI: delete_success = False export_success = False if not self.config.Runtime_Options__dryrun: - if export_success := ca.export_as_zip(new_file): + if ca.export_as_zip(new_file): + export_success = True if self.config.Runtime_Options__delete_original: try: filename_path.unlink(missing_ok=True) diff --git a/comictaggerlib/coverimagewidget.py b/comictaggerlib/coverimagewidget.py index 668c2fd..84e97c6 100644 --- a/comictaggerlib/coverimagewidget.py +++ b/comictaggerlib/coverimagewidget.py @@ -238,7 +238,8 @@ class CoverImageWidget(QtWidgets.QWidget): self.load_default() self.cover_fetcher = ImageFetcher(self.cache_folder) ImageFetcher.image_fetch_complete = self.image_fetch_complete.emit - if data := self.cover_fetcher.fetch(self.url_list[self.imageIndex]): + data = self.cover_fetcher.fetch(self.url_list[self.imageIndex]) + if data: self.cover_remote_fetch_complete(self.url_list[self.imageIndex], data) # called when the image is done loading from internet diff --git a/comictaggerlib/ctsettings/commandline.py b/comictaggerlib/ctsettings/commandline.py index 88aeb37..5bb7cce 100644 --- a/comictaggerlib/ctsettings/commandline.py +++ b/comictaggerlib/ctsettings/commandline.py @@ -300,8 +300,8 @@ def validate_commandline_settings(config: settngs.Config[ct_ns], parser: settngs letters.extend({f"{d}" for d in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" if os.path.exists(f"{d}:\\")} - {"C"}) for letter in letters: # look in some likely places for Windows machines - utils.add_to_path(rf"{letters}:\Program Files\WinRAR") - utils.add_to_path(rf"{letters}:\Program Files (x86)\WinRAR") + utils.add_to_path(rf"{letter}:\Program Files\WinRAR") + utils.add_to_path(rf"{letter}:\Program Files (x86)\WinRAR") else: if platform.system() == "Darwin": result = subprocess.run(("/usr/libexec/path_helper", "-s"), capture_output=True) diff --git a/comictaggerlib/main.py b/comictaggerlib/main.py index c145d3e..7282847 100644 --- a/comictaggerlib/main.py +++ b/comictaggerlib/main.py @@ -260,7 +260,7 @@ class App: comicapi.comicarchive.tags["cr"].enabled = False if len(self.talkers) < 1: - error = error = ( + error = ( "Failed to load any talkers, please re-install and check the log located in '" + str(self.config[0].Runtime_Options__config.user_log_dir) + "' for more details", diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 393b520..b65c92d 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -1810,8 +1810,7 @@ class TaggerWindow(QtWidgets.QMainWindow): if ct_md is not None: temp_opts = cast(ct_ns, settngs.get_namespace(self.config, True, True, True, False)[0]) - if dlg.cbxClearMetadata.isChecked(): - temp_opts.Auto_Tag__clear_tags + temp_opts.Auto_Tag__clear_tags = dlg.cbxClearMetadata.isChecked() md = prepare_metadata(md, ct_md, temp_opts) diff --git a/comictaggerlib/ui/talkeruigenerator.py b/comictaggerlib/ui/talkeruigenerator.py index 11a1daa..46f78f6 100644 --- a/comictaggerlib/ui/talkeruigenerator.py +++ b/comictaggerlib/ui/talkeruigenerator.py @@ -80,8 +80,6 @@ def generate_api_widgets( # get the actual config objects in case they have overwritten the default btn_test_row = None - le_key = None - le_url = None # only file settings are saved if key_option.file: diff --git a/comictalker/comiccacher.py b/comictalker/comiccacher.py index c240702..c084e1b 100644 --- a/comictalker/comiccacher.py +++ b/comictalker/comiccacher.py @@ -202,8 +202,6 @@ class ComicCacher: return results def get_series_info(self, series_id: str, source: str, expire_stale: bool = True) -> tuple[Series, bool] | None: - result: Series | None = None - with sqlite3.connect(self.db_file) as con: con.row_factory = sqlite3.Row cur = con.cursor()