diff --git a/setup/build.py b/setup/build.py index 8282960ab2..4e105cb6e6 100644 --- a/setup/build.py +++ b/setup/build.py @@ -441,7 +441,7 @@ class Build(Command): os.makedirs(x, exist_ok=True) pyqt_extensions, extensions = [], [] for ext in all_extensions: - if opts.only not in ('all', ext.name): + if opts.only not in {'all', ext.name}: continue if not is_ext_allowed(self.compiling_for, ext): continue diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 2ae1976872..5fdc263187 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -709,7 +709,7 @@ class KOBO(USBMS): # for calibre's reference path = self._main_prefix + path + '.kobo' # print('Path: ' + path) - elif (ContentType in {'6', '10'}) and ( + elif ContentType in {'6', '10'} and ( MimeType == 'application/x-kobo-epub+zip' or ( MimeType == 'application/epub+zip' and self.isTolinoDevice()) ): @@ -1797,7 +1797,7 @@ class KOBOTOUCH(KOBO): allow_shelves = False if show_debug: debug_print('KoboTouch:update_booklist - have a deleted book') - elif self.supports_kobo_archive() and (accessibility in {1, 2}): + elif self.supports_kobo_archive() and accessibility in {1, 2}: playlist_map[lpath].append('Archived') allow_shelves = True @@ -2192,7 +2192,7 @@ class KOBOTOUCH(KOBO): if oncard == 'cardb': print('path from_contentid cardb') - elif (ContentType in {'6', '10'}): + elif ContentType in {'6', '10'}: if (MimeType == 'application/octet-stream'): # Audiobooks purchased from Kobo are in a different location. path = self._main_prefix + KOBO_ROOT_DIR_NAME + '/audiobook/' + path elif (MimeType == 'audio/mpeg' and self.isTolinoDevice()): diff --git a/src/calibre/ebooks/lrf/pylrs/pylrfopt.py b/src/calibre/ebooks/lrf/pylrs/pylrfopt.py index d5b9d0ea68..2b07905f0e 100644 --- a/src/calibre/ebooks/lrf/pylrs/pylrfopt.py +++ b/src/calibre/ebooks/lrf/pylrs/pylrfopt.py @@ -2,7 +2,7 @@ def _optimize(tagList, tagName, conversion): # copy the tag of interest plus any text newTagList = [] for tag in tagList: - if tag.name in (tagName, 'rawtext'): + if tag.name in {tagName, 'rawtext'}: newTagList.append(tag) # now, eliminate any duplicates (leaving the last one) diff --git a/src/calibre/ebooks/mobi/reader/mobi6.py b/src/calibre/ebooks/mobi/reader/mobi6.py index 9394cfea62..4270fa9f4a 100644 --- a/src/calibre/ebooks/mobi/reader/mobi6.py +++ b/src/calibre/ebooks/mobi/reader/mobi6.py @@ -862,7 +862,7 @@ class MobiReader: l = self.mobi_html.find(b'<', end) r = self.mobi_html.find(b'>', end) anchor = b'' - if r > -1 and (r < l or l in (end, -1)): + if r > -1 and (r < l or l in {end, -1}): p = self.mobi_html.rfind(b'<', 0, end + 1) if (pos < end and p > -1 and not end_tag_re.match(self.mobi_html[p:r]) and not self.mobi_html[p:r + 1].endswith(b'/>')): diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py index b41781c29b..2c3c9b6229 100644 --- a/src/calibre/ebooks/pdf/reflow.py +++ b/src/calibre/ebooks/pdf/reflow.py @@ -278,7 +278,7 @@ class Text(Element): if m_self and m_other: self.raw = m_self.group(1) other.raw = m_other.group(1) - elif self.font_size_em not in (other.font_size_em, 1.0): + elif self.font_size_em not in {other.font_size_em, 1.0}: if not self.raw.startswith(r'{self.raw}' # Try to allow for a very large initial character @@ -948,7 +948,12 @@ class Page: t.tag = 'h2' # It won't get set later # Centered if left and right margins are within FACTOR% # Because indents can waver a bit, use between indent_min and indent_max as == indent - if (lmargin < indent_min or lmargin > indent_max) and lmargin > left_max and lmargin not in (xmargin, ymargin) and lmargin >= rmargin - rmargin * CENTER_FACTOR and lmargin <= rmargin + rmargin * CENTER_FACTOR and '"float:right"' not in t.raw: + if (lmargin < indent_min or lmargin > indent_max) \ + and lmargin > left_max \ + and lmargin not in {xmargin, ymargin} \ + and lmargin >= rmargin - rmargin*CENTER_FACTOR \ + and lmargin <= rmargin + rmargin*CENTER_FACTOR \ + and '"float:right"' not in t.raw: # and t.left + t.width + t.left >= self.width + l_offset - t.average_character_width \ # and t.left + t.width + t.left <= self.width + l_offset + t.average_character_width: t.align = 'C' diff --git a/src/calibre/ebooks/pdf/render/serialize.py b/src/calibre/ebooks/pdf/render/serialize.py index b4ba43ff48..8f19db1667 100644 --- a/src/calibre/ebooks/pdf/render/serialize.py +++ b/src/calibre/ebooks/pdf/render/serialize.py @@ -426,7 +426,7 @@ class PDFStream: if fmt == QImage.Format.Format_MonoLSB: image = image.convertToFormat(QImage.Format.Format_Mono) fmt = QImage.Format.Format_Mono - elif (fmt not in (QImage.Format.Format_RGB32, QImage.Format.Format_ARGB32)): + elif fmt not in (QImage.Format.Format_RGB32, QImage.Format.Format_ARGB32): image = image.convertToFormat(QImage.Format.Format_ARGB32) fmt = QImage.Format.Format_ARGB32 diff --git a/src/calibre/ebooks/rtf2xml/inline.py b/src/calibre/ebooks/rtf2xml/inline.py index 57a568c2cd..197890c412 100644 --- a/src/calibre/ebooks/rtf2xml/inline.py +++ b/src/calibre/ebooks/rtf2xml/inline.py @@ -400,7 +400,15 @@ class Inline: for line in read_obj: token = line[0:-1] self.__token_info = '' - if token in {'txHH', read(4))