diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 3d0a403429..3b9c56e15c 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -1742,7 +1742,8 @@ class KOBOTOUCH(KOBO): if show_debug: debug_print(f"KoboTouch:update_booklist - title='{title}'", f'ContentType={ContentType}', 'isdownloaded=', isdownloaded) debug_print( - f' prefix={prefix}, DateCreated={DateCreated}, readstatus={readstatus}, MimeType={MimeType}, expired={expired}, favouritesindex={favouritesindex}, accessibility={accessibility}, isdownloaded={isdownloaded}') + f' prefix={prefix}, DateCreated={DateCreated}, readstatus={readstatus}, MimeType={MimeType},' + f' expired={expired}, favouritesindex={favouritesindex}, accessibility={accessibility}, isdownloaded={isdownloaded}') changed = False try: lpath = path.partition(self.normalize_path(prefix))[2] @@ -2720,7 +2721,8 @@ class KOBOTOUCH(KOBO): debug_print('KoboTouch:update_device_database_collections - about to clear empty bookshelves') self.delete_empty_bookshelves(connection) debug_print(f'KoboTouch:update_device_database_collections - Number of series set={self.series_set} Number of books={books_in_library}') - debug_print(f'KoboTouch:update_device_database_collections - Number of core metadata set={self.core_metadata_set} Number of books={books_in_library}') + debug_print(f'KoboTouch:update_device_database_collections - Number of core metadata set={self.core_metadata_set}' + f' Number of books={books_in_library}') self.dump_bookshelves(connection) @@ -2914,7 +2916,8 @@ class KOBOTOUCH(KOBO): for ending, cover_options in self.cover_file_endings().items(): kobo_size, min_dbversion, max_dbversion, is_full_size = cover_options if show_debug: - debug_print(f'KoboTouch:_upload_cover - library_cover_size={library_cover_size} -> kobo_size={kobo_size}, min_dbversion={min_dbversion} max_dbversion={max_dbversion}, is_full_size={is_full_size}') + debug_print(f'KoboTouch:_upload_cover - library_cover_size={library_cover_size} -> kobo_size={kobo_size},' + f' min_dbversion={min_dbversion} max_dbversion={max_dbversion}, is_full_size={is_full_size}') if self.dbversion >= min_dbversion and self.dbversion <= max_dbversion: if show_debug: diff --git a/src/calibre/devices/winusb.py b/src/calibre/devices/winusb.py index 7b70938fc9..b183aae199 100644 --- a/src/calibre/devices/winusb.py +++ b/src/calibre/devices/winusb.py @@ -179,7 +179,10 @@ class USB_DEVICE_DESCRIPTOR(Structure): ) def __repr__(self): - return f'USBDevice(class=0x{self.bDeviceClass:x} sub_class=0x{self.bDeviceSubClass:x} protocol=0x{self.bDeviceProtocol:x} vendor_id=0x{self.idVendor:x} product_id=0x{self.idProduct:x} bcd=0x{self.bcdDevice:x} manufacturer={self.iManufacturer} product={self.iProduct} serial_number={self.iSerialNumber})' + return ( + f'USBDevice(class=0x{self.bDeviceClass:x} sub_class=0x{self.bDeviceSubClass:x} protocol=0x{self.bDeviceProtocol:x}' + f' vendor_id=0x{self.idVendor:x} product_id=0x{self.idProduct:x} bcd=0x{self.bcdDevice:x} manufacturer={self.iManufacturer}' + f'product={self.iProduct} serial_number={self.iSerialNumber})') class USB_ENDPOINT_DESCRIPTOR(Structure): diff --git a/src/calibre/ebooks/lit/reader.py b/src/calibre/ebooks/lit/reader.py index 4af6a3b118..f6df491afd 100644 --- a/src/calibre/ebooks/lit/reader.py +++ b/src/calibre/ebooks/lit/reader.py @@ -396,7 +396,7 @@ class DirectoryEntry: self.size = size def __repr__(self): - return f'DirectoryEntry(name={repr(self.name)}, section={self.section}, offset={self.offset}, size={self.size})' + return f'DirectoryEntry(name={self.name!r}, section={self.section}, offset={self.offset}, size={self.size})' def __str__(self): return repr(self) @@ -427,7 +427,9 @@ class ManifestItem: return self.internal == other def __repr__(self): - return f"ManifestItem(internal={self.internal!r}, path={self.path!r}, mime_type={self.mime_type!r}, offset={self.offset}, root={self.root!r}, state={self.state!r})" + return ( + f'ManifestItem(internal={self.internal!r}, path={self.path!r}, mime_type={self.mime_type!r},' + f' offset={self.offset}, root={self.root!r}, state={self.state!r})') def preserve(function): diff --git a/src/calibre/ebooks/lrf/objects.py b/src/calibre/ebooks/lrf/objects.py index 485f5a9bc4..dc2994aec8 100644 --- a/src/calibre/ebooks/lrf/objects.py +++ b/src/calibre/ebooks/lrf/objects.py @@ -932,7 +932,9 @@ class Image(LRFObject): data = property(fget=lambda self: self._document.objects[self.refstream].stream) def __str__(self): - return f'\n' + return ( + f'\n') class PutObj(EmptyPageElement): diff --git a/src/calibre/ebooks/mobi/debug/mobi6.py b/src/calibre/ebooks/mobi/debug/mobi6.py index 3abe56b3e7..99a55f6555 100644 --- a/src/calibre/ebooks/mobi/debug/mobi6.py +++ b/src/calibre/ebooks/mobi/debug/mobi6.py @@ -591,7 +591,7 @@ class TBSIndexing: # {{{ if entries: ans.append(f'\t{typ}:') for x in entries: - ans.append(f"\t\tIndex Entry: {x.index} (Parent index: {x.parent_index}, Depth: {x.depth}, Offset: {x.offset}, Size: {x.size}) [{x.label}]") + ans.append(f'\t\tIndex Entry: {x.index} (Parent index: {x.parent_index}, Depth: {x.depth}, Offset: {x.offset}, Size: {x.size}) [{x.label}]') def bin4(num): ans = bin(num)[2:] @@ -646,7 +646,9 @@ class TBSIndexing: # {{{ raise ValueError('Dont know how to interpret flags' f' {extra!r} while reading section transitions') nsi = self.get_index(psi.index+1) - ans.append(f'Last article in this record of section {psi.index} (relative to next section index [{nsi.index}]): {ai} [{ai + nsi.index} absolute index]') + ans.append( + f'Last article in this record of section {psi.index} (relative to next section index [{nsi.index}]):' + f' {ai} [{ai + nsi.index} absolute index]') psi = nsi continue @@ -654,9 +656,9 @@ class TBSIndexing: # {{{ num = extra.get(0b0100, None) if num is None: - msg = f"The section {psi.index} has at most one article in this record" + msg = f'The section {psi.index} has at most one article in this record' else: - msg = f"Number of articles in this record of section {psi.index}: {num}" + msg = f'Number of articles in this record of section {psi.index}: {num}' ans.append(msg) offset = extra.get(0b0001, None) @@ -664,7 +666,9 @@ class TBSIndexing: # {{{ if offset == 0: ans.append(f'This record is spanned by the article:{ai + psi.index}') else: - ans.append(f'->Offset to start of next section ({psi.index + 1}) from start of record: {offset} [{offset + record_offset} absolute offset]') + ans.append( + f'->Offset to start of next section ({psi.index + 1}) from start of record:' + f' {offset} [{offset + record_offset} absolute offset]') return byts # }}} diff --git a/src/calibre/ebooks/pdb/ztxt/reader.py b/src/calibre/ebooks/pdb/ztxt/reader.py index 54141c6901..ce51ce19fd 100644 --- a/src/calibre/ebooks/pdb/ztxt/reader.py +++ b/src/calibre/ebooks/pdb/ztxt/reader.py @@ -48,7 +48,8 @@ class Reader(FormatReader): vmajor = (self.header_record.version & 0x0000FF00) >> 8 vminor = self.header_record.version & 0x000000FF if vmajor < 1 or (vmajor == 1 and vminor < 40): - raise zTXTError(f'Unsupported ztxt version ({vmajor}.{vminor}). Only versions newer than {SUPPORTED_VERSION[0]}.{SUPPORTED_VERSION[1]} are supported.') + raise zTXTError(f'Unsupported ztxt version ({vmajor}.{vminor}).' + f' Only versions newer than {SUPPORTED_VERSION[0]}.{SUPPORTED_VERSION[1]} are supported.') if (self.header_record.flags & 0x01) == 0: raise zTXTError('Only compression method 1 (random access) is supported') diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py index abcf8a7883..f4a916141f 100644 --- a/src/calibre/ebooks/pdf/reflow.py +++ b/src/calibre/ebooks/pdf/reflow.py @@ -271,8 +271,8 @@ class Text(Element): if self.font_size_em == other.font_size_em \ and False \ and self.font.id == other.font.id \ - and re.match(r'$', self.raw) m_other = re.match(r'^(.+)$', other.raw) @@ -281,7 +281,7 @@ class Text(Element): other.raw = m_other.group(1) elif self.font_size_em != other.font_size_em \ and self.font_size_em != 1.00: - if re.match(r'{self.raw}' # Try to allow for a very large initial character elif len(self.text_as_string) <= 2 \ diff --git a/src/calibre/gui2/tweak_book/editor/snippets.py b/src/calibre/gui2/tweak_book/editor/snippets.py index 8a91389c7b..6ef59672ea 100644 --- a/src/calibre/gui2/tweak_book/editor/snippets.py +++ b/src/calibre/gui2/tweak_book/editor/snippets.py @@ -159,7 +159,9 @@ class TabStop(str): return self def __repr__(self): - return f'TabStop(text={str.__repr__(self)} num={self.num} start={self.start} is_mirror={self.is_mirror} takes_selection={self.takes_selection} is_toplevel={self.is_toplevel})' + return ( + f'TabStop(text={str.__repr__(self)} num={self.num} start={self.start} is_mirror={self.is_mirror}' + f' takes_selection={self.takes_selection} is_toplevel={self.is_toplevel})') def parse_template(template, start_offset=0, is_toplevel=True, grouped=True): diff --git a/src/calibre/gui2/update.py b/src/calibre/gui2/update.py index a34c82520e..eaf4be710a 100644 --- a/src/calibre/gui2/update.py +++ b/src/calibre/gui2/update.py @@ -219,7 +219,7 @@ class UpdateMixin: green, _('Update available'), version_url, calibre_version, plt) else: plt = ngettext('plugin update available', 'plugin updates available', number_of_plugin_updates) - msg = f"{number_of_plugin_updates} {plt}" + msg = f'{number_of_plugin_updates} {plt}' self.status_bar.update_label.setText(msg) self.status_bar.update_label.setVisible(True) diff --git a/src/calibre/utils/exim.py b/src/calibre/utils/exim.py index b28cfcee9f..92e8be0a56 100644 --- a/src/calibre/utils/exim.py +++ b/src/calibre/utils/exim.py @@ -377,7 +377,8 @@ class Importer: raise ValueError(f'The exported data in {name} is not valid, tail too small') part_num, version, is_last = struct.unpack(Exporter.TAIL_FMT, raw) if version > Exporter.VERSION: - raise ValueError(f'The exported data in {name} is not valid, version ({version}) is higher than maximum supported version. You might need to upgrade calibre first.') + raise ValueError(f'The exported data in {name} is not valid, version ({version})' + ' is higher than maximum supported version. You might need to upgrade calibre first.') part_map[part_num] = path, is_last, size_of_part if self.version == -1: self.version = version diff --git a/src/calibre/utils/mem.py b/src/calibre/utils/mem.py index 72d0acc9ad..3687eb1d7b 100644 --- a/src/calibre/utils/mem.py +++ b/src/calibre/utils/mem.py @@ -47,4 +47,4 @@ def diff_hists(h1, h2): if k not in h2: h2[k] = 0 if h1[k] != h2[k]: - print(f"{k}: {h1[k]} -> {h2[k]} ({h2[k] > h1[k] and '+' or ''}{h2[k] - h1[k]})") + print(f"{k}: {h1[k]} -> {h2[k]} ({(h2[k] > h1[k] and '+') or ''}{h2[k] - h1[k]})")