From 53c2f34a4c6b5de8570fd8fe25e58e4f6fa24b71 Mon Sep 17 00:00:00 2001 From: un-pogaz <46523284+un-pogaz@users.noreply.github.com> Date: Fri, 10 Oct 2025 08:24:39 +0200 Subject: [PATCH] redeclared assigned name (manual) ruff 'PLW0127' --- pyproject.toml | 2 +- src/calibre/devices/kobo/driver.py | 1 - src/calibre/ebooks/__init__.py | 1 - src/calibre/ebooks/covers.py | 1 - src/calibre/ebooks/docx/to_html.py | 2 -- src/calibre/ebooks/metadata/opf2.py | 1 - src/calibre/gui2/main.py | 1 - src/calibre/gui2/tag_browser/model.py | 1 - src/calibre/gui2/tweak_book/editor/smarts/html.py | 2 +- src/calibre/gui2/tweak_book/undo.py | 2 -- src/calibre/library/database2.py | 1 - src/calibre/utils/lock.py | 1 - src/calibre/utils/rapydscript.py | 1 - 13 files changed, 2 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6bc24ebb09..d5697b7ca1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,7 +107,7 @@ ignore = [ 'E402', 'E741', 'UP012', 'UP030', 'C413', 'C420', 'PIE790', 'ISC003', 'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF100', - 'PLE1205', 'PLW0602', 'PLW0603', 'PLW1510', 'PLW1641', 'PLW2901', 'PLW0127', + 'PLE1205', 'PLW0602', 'PLW0603', 'PLW1510', 'PLW1641', 'PLW2901', 'RUF059', # unused unpacked variable ] select = [ diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 8a8ce232d4..29a98c8c7f 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -1222,7 +1222,6 @@ class KOBO(USBMS): if bookmark_extension: for vol in storage: bkmk_path = path_map[book_id]['path'] - bkmk_path = bkmk_path if os.path.exists(bkmk_path): path_map[book_id] = bkmk_path book_ext[book_id] = book_extension diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index ea39200234..4688081878 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -201,7 +201,6 @@ def unit_convert(value, base, font, dpi, body_font_size=12): elif unit in ('ex', 'en'): # This is a hack for ex since we have no way to know # the x-height of the font - font = font result = value * font * 0.5 elif unit == 'pc': result = value * 12.0 diff --git a/src/calibre/ebooks/covers.py b/src/calibre/ebooks/covers.py index dcd6217bdd..0341394ca0 100644 --- a/src/calibre/ebooks/covers.py +++ b/src/calibre/ebooks/covers.py @@ -220,7 +220,6 @@ class Block: def layout_text(prefs, img, title, subtitle, footer, max_height, style): width = img.width() - 2 * style.hmargin - title, subtitle, footer = title, subtitle, footer title_font = QFont(prefs.title_font_family or 'Liberation Serif') title_font.setPixelSize(prefs.title_font_size) title_font.setStyleStrategy(QFont.StyleStrategy.PreferAntialias) diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py index 8e7eb1cd66..2906123dd4 100644 --- a/src/calibre/ebooks/docx/to_html.py +++ b/src/calibre/ebooks/docx/to_html.py @@ -299,8 +299,6 @@ class Convert: if name is None: cname = self.docx.document_name.split('/') cname[-1] = defname - if self.docx.exists('/'.join(cname)): - name = name if name and name.startswith('word/word') and not self.docx.exists(name): name = name.partition('/')[2] return name diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 9f47019830..d3c5d769cb 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -89,7 +89,6 @@ class Resource: # {{{ path = path.decode(filesystem_encoding) self.path = path else: - href_or_path = href_or_path url = urlparse(href_or_path) if url[0] not in ('', 'file'): self._href = href_or_path diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 5b46572a6e..f42630da7c 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -83,7 +83,6 @@ def find_portable_library(): lib = None q = os.path.basename(lp) for c in candidates: - c = c if c.lower() == q.lower(): lib = os.path.join(base, c) break diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index f5c04d383f..d98a177332 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -40,7 +40,6 @@ def bf(): if _bf is None: _bf = QFont() _bf.setBold(True) - _bf = (_bf) return _bf diff --git a/src/calibre/gui2/tweak_book/editor/smarts/html.py b/src/calibre/gui2/tweak_book/editor/smarts/html.py index da6a8bd741..d97d4ba02e 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/html.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/html.py @@ -108,7 +108,7 @@ def find_closest_containing_tag(block, offset, max_tags=sys.maxsize): return Tag(block, boundary, eblock, eboundary, self_closing=True) return find_closest_containing_tag(eblock, eboundary.offset + 1) stack = [] - block, tag_end = block, boundary + tag_end = boundary while block is not None and max_tags > 0: sblock, tag_start = prev_tag_boundary(block, tag_end.offset) if sblock is None or not tag_start.is_start: diff --git a/src/calibre/gui2/tweak_book/undo.py b/src/calibre/gui2/tweak_book/undo.py index 4a56a5a4a7..a096cd30e5 100644 --- a/src/calibre/gui2/tweak_book/undo.py +++ b/src/calibre/gui2/tweak_book/undo.py @@ -71,8 +71,6 @@ class GlobalUndoHistory(QAbstractListModel): msg = _('Current state') + ('' if not msg else _(' [was %s]') % msg) elif not msg: msg = _('[Unnamed state]') - else: - msg = msg return msg def label_for_container(self, container): diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index fe8f3676fe..c9bc8df526 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1602,7 +1602,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): return self.add_format(book_id, nfmt, f, index_is_id=True, notify=notify) def original_fmt(self, book_id, fmt): - fmt = fmt nfmt = (f'ORIGINAL_{fmt}').upper() opath = self.format_abspath(book_id, nfmt, index_is_id=True) return fmt if opath is None else nfmt diff --git a/src/calibre/utils/lock.py b/src/calibre/utils/lock.py index 21bc18f6a0..9ece78015f 100644 --- a/src/calibre/utils/lock.py +++ b/src/calibre/utils/lock.py @@ -145,7 +145,6 @@ elif islinux: name = '{}-singleinstance-{}-{}'.format( __appname__, (os.geteuid() if per_user else ''), name ) - name = name address = '\0' + name.replace(' ', '_') sock = socket.socket(family=socket.AF_UNIX) try: diff --git a/src/calibre/utils/rapydscript.py b/src/calibre/utils/rapydscript.py index 687a552dd0..6b820d9c82 100644 --- a/src/calibre/utils/rapydscript.py +++ b/src/calibre/utils/rapydscript.py @@ -525,7 +525,6 @@ def create_pot(source_files): for fname in source_files: with open(fname, 'rb') as f: code = f.read().decode('utf-8') - fname = fname c.eval('RapydScript.gettext_parse(window.catalog, {}, {}); 1'.format(*map(json.dumps, (code, fname)))) buf = c.eval('ans = []; RapydScript.gettext_output(window.catalog, window.gettext_options, ans.push.bind(ans)); ans;')