diff --git a/recipes/business_today.recipe b/recipes/business_today.recipe index 4db915ee96..cab351e15a 100644 --- a/recipes/business_today.recipe +++ b/recipes/business_today.recipe @@ -98,8 +98,7 @@ class BT(BasicNewsRecipe): # Done with the sorted feeds for i in feedSort: - if i in sections: - del sections[i] + sections.pop(i, None) # Append what is left over... diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml index a1bca3d6ed..44033b2eab 100644 --- a/ruff-strict-pep8.toml +++ b/ruff-strict-pep8.toml @@ -32,6 +32,7 @@ select = [ 'Q', 'UP', 'YTT', 'TID', 'C4', 'COM818', 'RUF', # nota: RUF can flag many unsolicited errors # preview rules + 'RUF051', 'RUF056', # useless dict operation ] [lint.per-file-ignores] diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 421098b535..685dd6a2a3 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -517,7 +517,7 @@ class Device(DeviceConfig, DevicePlugin): devnodes.append(node) devnodes += list(repeat(None, 3)) - ans = ['/dev/'+x if ok.get(x, False) else None for x in devnodes] + ans = ['/dev/'+x if ok.get(x) else None for x in devnodes] ans.sort(key=lambda x: x[5:] if x else 'zzzzz') return self.linux_swap_drives(ans[:3]) diff --git a/src/calibre/ebooks/metadata/odt.py b/src/calibre/ebooks/metadata/odt.py index 00dc0237d8..c0c660004e 100644 --- a/src/calibre/ebooks/metadata/odt.py +++ b/src/calibre/ebooks/metadata/odt.py @@ -119,19 +119,19 @@ def get_metadata(stream, extract_cover=True): if data.get('opf.metadata'): # custom metadata contains OPF information opfmeta = True - if data.get('opf.titlesort', ''): + if data.get('opf.titlesort'): mi.title_sort = data['opf.titlesort'] - if data.get('opf.authors', ''): + if data.get('opf.authors'): mi.authors = string_to_authors(data['opf.authors']) - if data.get('opf.authorsort', ''): + if data.get('opf.authorsort'): mi.author_sort = data['opf.authorsort'] - if data.get('opf.isbn', ''): + if data.get('opf.isbn'): isbn = check_isbn(data['opf.isbn']) if isbn is not None: mi.isbn = isbn - if data.get('opf.publisher', ''): + if data.get('opf.publisher'): mi.publisher = data['opf.publisher'] - if data.get('opf.pubdate', ''): + if data.get('opf.pubdate'): mi.pubdate = parse_date(data['opf.pubdate'], assume_utc=True) if data.get('opf.identifiers'): try: @@ -143,14 +143,14 @@ def get_metadata(stream, extract_cover=True): mi.rating = max(0, min(float(data['opf.rating']), 10)) except Exception: pass - if data.get('opf.series', ''): + if data.get('opf.series'): mi.series = data['opf.series'] - if data.get('opf.seriesindex', ''): + if data.get('opf.seriesindex'): try: mi.series_index = float(data['opf.seriesindex']) except Exception: mi.series_index = 1.0 - if data.get('opf.language', ''): + if data.get('opf.language'): cl = canonicalize_lang(data['opf.language']) if cl: mi.languages = [cl] diff --git a/src/calibre/gui2/keyboard.py b/src/calibre/gui2/keyboard.py index 37f9b584dd..dbbc7562ab 100644 --- a/src/calibre/gui2/keyboard.py +++ b/src/calibre/gui2/keyboard.py @@ -318,10 +318,8 @@ class ConfigModel(SearchQueryParser, QAbstractItemModel): sc = node.data un = sc['unique_name'] if sc['set_to_default']: - if un in kmap: - del kmap[un] - if un in options_map: - del options_map[un] + kmap.pop(un, None) + options_map.pop(un, None) else: if sc['persist_shortcut']: options_map[un] = options_map.get(un, {})