mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
parenthesize chained operators (auto-fix)
ruff 'RUF021'
This commit is contained in:
parent
93aa2ff492
commit
76c091c975
@ -20,7 +20,7 @@ quote-style = 'single'
|
||||
ignore = [
|
||||
'E402', 'E722', 'E741',
|
||||
'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420',
|
||||
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF010', 'RUF012', 'RUF013', 'RUF015', 'RUF021', 'RUF031', 'RUF034', 'RUF100',
|
||||
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF010', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF034', 'RUF100',
|
||||
]
|
||||
select = [
|
||||
'E', 'F', 'I', 'W', 'INT',
|
||||
|
@ -163,7 +163,7 @@ def format_group(db, notify_changes, is_remote, args):
|
||||
mi = metadata_from_formats(paths)
|
||||
if mi.title is None:
|
||||
return None, set(), set(), False
|
||||
if cover_data and not mi.cover_data or not mi.cover_data[1]:
|
||||
if (cover_data and not mi.cover_data) or not mi.cover_data[1]:
|
||||
mi.cover_data = 'jpeg', cover_data
|
||||
format_map = create_format_map(paths)
|
||||
added_ids, updated_ids, duplicates = do_adding(
|
||||
|
@ -253,7 +253,7 @@ class Restore(Thread):
|
||||
dest = self.link_maps.setdefault(field, {})
|
||||
for item, link in lmap.items():
|
||||
existing_link, timestamp = dest.get(item, (None, None))
|
||||
if existing_link is None or existing_link != link and timestamp < mi.timestamp:
|
||||
if existing_link is None or (existing_link != link and timestamp < mi.timestamp):
|
||||
dest[item] = link, mi.timestamp
|
||||
|
||||
def create_cc_metadata(self):
|
||||
|
@ -1782,7 +1782,7 @@ class KOBOTOUCH(KOBO):
|
||||
# - FW2.1.2 beta, DBVersion == 56, accessibility == -1:
|
||||
# So, the following should be OK
|
||||
if self.is_false_value(isdownloaded):
|
||||
if self.dbversion < 56 and accessibility <= 1 or self.dbversion >= 56 and accessibility == -1:
|
||||
if (self.dbversion < 56 and accessibility <= 1) or (self.dbversion >= 56 and accessibility == -1):
|
||||
playlist_map[lpath].append('Deleted')
|
||||
allow_shelves = False
|
||||
if show_debug:
|
||||
@ -2689,7 +2689,7 @@ class KOBOTOUCH(KOBO):
|
||||
self.reset_favouritesindex(connection, oncard)
|
||||
|
||||
# Set the series info and cleanup the bookshelves only if the firmware supports them and the user has set the options.
|
||||
if (self.supports_bookshelves and self.manage_collections or self.supports_series()) and (
|
||||
if ((self.supports_bookshelves and self.manage_collections) or self.supports_series()) and (
|
||||
have_bookshelf_attributes or update_series_details or update_core_metadata):
|
||||
debug_print('KoboTouch:update_device_database_collections - managing bookshelves and series.')
|
||||
|
||||
@ -4204,7 +4204,7 @@ class KOBOTOUCH(KOBO):
|
||||
if not self.debugging_title and not self.debugging_title == '':
|
||||
self.debugging_title = self.get_debugging_title()
|
||||
try:
|
||||
is_debugging = len(self.debugging_title) > 0 and title.lower().find(self.debugging_title.lower()) >= 0 or len(title) == 0
|
||||
is_debugging = (len(self.debugging_title) > 0 and title.lower().find(self.debugging_title.lower()) >= 0) or len(title) == 0
|
||||
except:
|
||||
debug_print(("KoboTouch::is_debugging_title - Exception checking debugging title for title '{}'.").format(title))
|
||||
is_debugging = False
|
||||
|
@ -279,7 +279,7 @@ class MetadataUpdater:
|
||||
|
||||
def hexdump(self, src, length=16):
|
||||
# Diagnostic
|
||||
FILTER=''.join([(len(repr(codepoint_to_chr(x)))==3) and codepoint_to_chr(x) or '.' for x in range(256)])
|
||||
FILTER=''.join([((len(repr(codepoint_to_chr(x)))==3) and codepoint_to_chr(x)) or '.' for x in range(256)])
|
||||
N=0
|
||||
result=''
|
||||
while src:
|
||||
|
@ -154,7 +154,7 @@ class MetadataUpdater:
|
||||
|
||||
def dump_hex(self, src, length=16):
|
||||
''' Diagnostic '''
|
||||
FILTER=''.join([(len(repr(codepoint_to_chr(x)))==3) and codepoint_to_chr(x) or '.' for x in range(256)])
|
||||
FILTER=''.join([((len(repr(codepoint_to_chr(x)))==3) and codepoint_to_chr(x)) or '.' for x in range(256)])
|
||||
N=0
|
||||
result=''
|
||||
while src:
|
||||
|
@ -67,8 +67,8 @@ def extract_book(pathtoebook, tdir, log=None, view_kepub=False, processed=False,
|
||||
if not only_input_plugin:
|
||||
# Run the HTML preprocess/parsing from the conversion pipeline as
|
||||
# well
|
||||
if (processed or plumber.input_fmt.lower() in {'pdb', 'pdf', 'rb'} and
|
||||
not hasattr(pathtoopf, 'manifest')):
|
||||
if (processed or (plumber.input_fmt.lower() in {'pdb', 'pdf', 'rb'} and
|
||||
not hasattr(pathtoopf, 'manifest'))):
|
||||
if hasattr(pathtoopf, 'manifest'):
|
||||
pathtoopf = write_oebbook(pathtoopf, tdir)
|
||||
pathtoopf = create_oebbook(log, pathtoopf, plumber.opts)
|
||||
|
@ -89,7 +89,7 @@ class RemoveFakeMargins:
|
||||
pass
|
||||
else:
|
||||
if ((hasattr(ti, 'startswith') and ti.startswith('-')) or
|
||||
isinstance(ti, numbers.Number) and ti < 0):
|
||||
(isinstance(ti, numbers.Number) and ti < 0)):
|
||||
raise NegativeTextIndent()
|
||||
return style.marginLeft, style.marginRight, style
|
||||
return '', '', None
|
||||
|
@ -649,7 +649,7 @@ def create_copy_links(menu, data=None):
|
||||
field = data.get('field')
|
||||
if data['type'] == 'author':
|
||||
field = 'authors'
|
||||
if field and field in ('tags', 'series', 'publisher', 'authors') or is_category(field):
|
||||
if (field and field in ('tags', 'series', 'publisher', 'authors')) or is_category(field):
|
||||
name = data['name' if data['type'] == 'author' else 'value']
|
||||
eq = f'{field}:"={name}"'.encode().hex()
|
||||
link_action(_('Link to show books matching {} in calibre').format(name),
|
||||
|
@ -670,7 +670,7 @@ class CentralContainer(QWidget):
|
||||
hs = h.state
|
||||
if hs is HandleState.both_visible or hs is HandleState.only_side_visible:
|
||||
height = normal_handle_width
|
||||
if hs is HandleState.only_main_visible and h is self.bottom_handle or (h is self.top_handle and self.separate_cover_browser):
|
||||
if (hs is HandleState.only_main_visible and h is self.bottom_handle) or (h is self.top_handle and self.separate_cover_browser):
|
||||
height = 0
|
||||
h.resize(int(central_width), int(height))
|
||||
available_height -= height
|
||||
|
@ -133,7 +133,7 @@ class DownloadDialog(QDialog): # {{{
|
||||
|
||||
def dnd_has_image(md):
|
||||
# Chromium puts image data into application/octet-stream
|
||||
return md.hasImage() or md.hasFormat('application/octet-stream') and what(None, bytes(md.data('application/octet-stream'))) in image_extensions()
|
||||
return md.hasImage() or (md.hasFormat('application/octet-stream') and what(None, bytes(md.data('application/octet-stream'))) in image_extensions())
|
||||
|
||||
|
||||
def data_as_string(f, md):
|
||||
|
@ -1234,9 +1234,9 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
if fm_dest['kind'] == 'user':
|
||||
fm_src = self.db.metadata_for_field(md.column_name)
|
||||
if md.column_name in ['authors', 'publisher', 'series'] or \
|
||||
(fm_src['is_custom'] and (
|
||||
((fm_src['is_custom'] and (
|
||||
fm_src['datatype'] in ['series', 'text', 'enumeration'] and
|
||||
not fm_src['is_multiple'])or
|
||||
not fm_src['is_multiple']))or
|
||||
(fm_src['datatype'] == 'composite' and
|
||||
fm_src['display'].get('make_category', False))):
|
||||
mime = 'application/calibre+from_library'
|
||||
|
@ -203,7 +203,7 @@ class Restore(Thread):
|
||||
alm = mi.get('author_link_map', {})
|
||||
for author, link in iteritems(alm):
|
||||
existing_link, timestamp = self.authors_links.get(author, (None, None))
|
||||
if existing_link is None or existing_link != link and timestamp < mi.timestamp:
|
||||
if existing_link is None or (existing_link != link and timestamp < mi.timestamp):
|
||||
self.authors_links[author] = (link, mi.timestamp)
|
||||
|
||||
def create_cc_metadata(self):
|
||||
|
@ -135,7 +135,7 @@ class Image:
|
||||
return width, height, fmt
|
||||
|
||||
def remove_border(self, fuzz=None):
|
||||
if fuzz is not None and fuzz < 0 or fuzz > 255:
|
||||
if (fuzz is not None and fuzz < 0) or fuzz > 255:
|
||||
fuzz = None
|
||||
self.img = remove_borders_from_image(self.img, fuzz)
|
||||
trim = remove_border
|
||||
|
@ -48,4 +48,4 @@ def diff_hists(h1, h2):
|
||||
h2[k] = 0
|
||||
if h1[k] != h2[k]:
|
||||
print('%s: %d -> %d (%s%d)' % (
|
||||
k, h1[k], h2[k], h2[k] > h1[k] and '+' or '', h2[k] - h1[k]))
|
||||
k, h1[k], h2[k], (h2[k] > h1[k] and '+') or '', h2[k] - h1[k]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user