diff --git a/recipes/alternatives_economiques.recipe b/recipes/alternatives_economiques.recipe index e13e57cc92..bcb98ccf74 100644 --- a/recipes/alternatives_economiques.recipe +++ b/recipes/alternatives_economiques.recipe @@ -92,7 +92,7 @@ class AlternativesEconomiques(BasicNewsRecipe): display_name = section_name.replace('-', ' ').title() articles.append((display_name, feed_articles[:self.max_articles_per_feed])) except Exception as e: - self.log.error(f'Error processing {section_name}: {str(e)}') + self.log.error(f'Error processing {section_name}: {e!s}') continue return articles @@ -133,7 +133,7 @@ class AlternativesEconomiques(BasicNewsRecipe): 'description': '' }) except Exception as e: - self.log.error(f'Error getting H1 title for {article_url}: {str(e)}') + self.log.error(f'Error getting H1 title for {article_url}: {e!s}') continue return feed_articles diff --git a/recipes/arret_sur_images.recipe b/recipes/arret_sur_images.recipe index 70a2a21fbc..b40642ecc0 100644 --- a/recipes/arret_sur_images.recipe +++ b/recipes/arret_sur_images.recipe @@ -125,7 +125,7 @@ class ArretSurImages(BasicNewsRecipe): else: print("Échec de l'authentification - Vérifiez vos identifiants") except Exception as e: - print(f"Erreur lors de l'authentification: {str(e)}") + print(f"Erreur lors de l'authentification: {e!s}") return br def get_article_url(self, article): @@ -162,7 +162,7 @@ class ArretSurImages(BasicNewsRecipe): ''' except Exception as e: - print(f'Erreur preprocessing HTML: {str(e)}') + print(f'Erreur preprocessing HTML: {e!s}') return raw_html def preprocess_html(self, soup): @@ -186,11 +186,11 @@ class ArretSurImages(BasicNewsRecipe): else: tag.replace_with(img_tag) except Exception as e: - print(f'Erreur processing image: {str(e)}') + print(f'Erreur processing image: {e!s}') tag.decompose() else: tag.decompose() return soup except Exception as e: - print(f'Erreur preprocessing HTML: {str(e)}') + print(f'Erreur preprocessing HTML: {e!s}') return soup diff --git a/recipes/le_canard_enchaine.recipe b/recipes/le_canard_enchaine.recipe index 10a8aaf0fa..950d0c50d3 100644 --- a/recipes/le_canard_enchaine.recipe +++ b/recipes/le_canard_enchaine.recipe @@ -122,7 +122,7 @@ class LeCanardEnchaine(BasicNewsRecipe): print(f' {len(unique_articles)} articles trouvés') except Exception as e: - print(f'Erreur sur {section_title}: {str(e)}') + print(f'Erreur sur {section_title}: {e!s}') return feeds diff --git a/recipes/newrepublicmag.recipe b/recipes/newrepublicmag.recipe index 8e66503405..621944570c 100644 --- a/recipes/newrepublicmag.recipe +++ b/recipes/newrepublicmag.recipe @@ -252,7 +252,7 @@ fragment ArticlePageFields on Article { {lede_image_html} - {str(body_soup)} + {body_soup!s} {author_bios_html} ''' diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml index 3e26e03f61..21945f862b 100644 --- a/ruff-strict-pep8.toml +++ b/ruff-strict-pep8.toml @@ -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', 'RUF031', 'RUF034', 'RUF100', + 'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF034', 'RUF100', ] select = [ 'E', 'F', 'I', 'W', 'INT', diff --git a/src/calibre/ebooks/lrf/objects.py b/src/calibre/ebooks/lrf/objects.py index d20805c349..b19a4696a1 100644 --- a/src/calibre/ebooks/lrf/objects.py +++ b/src/calibre/ebooks/lrf/objects.py @@ -86,7 +86,7 @@ class LRFObject: if h[1] != '' and h[0] != '': setattr(self, h[0], val) else: - raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {str(tag)}') + raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag!s}') def __iter__(self): yield from range(0) @@ -129,7 +129,7 @@ class LRFContentObject(LRFObject): func, args = action[0], (action[1],) getattr(self, func)(tag, *args) else: - raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {str(tag)}') + raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag!s}') def __iter__(self): yield from self._contents diff --git a/src/calibre/ebooks/lrf/tags.py b/src/calibre/ebooks/lrf/tags.py index ffc53e45dd..cef0ba6dd0 100644 --- a/src/calibre/ebooks/lrf/tags.py +++ b/src/calibre/ebooks/lrf/tags.py @@ -205,7 +205,7 @@ class Tag: s = 'Tag %04X ' % self.id if self.name: s += self.name - s += f' at {self.offset:08X}, contents: {repr(self.contents)}' + s += f' at {self.offset:08X}, contents: {self.contents!r}' return s @property diff --git a/src/calibre/ebooks/metadata/topaz.py b/src/calibre/ebooks/metadata/topaz.py index 54106e7cfe..9829326e2b 100644 --- a/src/calibre/ebooks/metadata/topaz.py +++ b/src/calibre/ebooks/metadata/topaz.py @@ -168,7 +168,7 @@ class MetadataUpdater: def dump_metadata(self): ''' Diagnostic ''' for tag in self.metadata: - print(f'{tag}: {repr(self.metadata[tag])}') + print(f'{tag}: {self.metadata[tag]!r}') def encode_vwi(self,value): ans = [] diff --git a/src/calibre/ebooks/pdf/html_writer.py b/src/calibre/ebooks/pdf/html_writer.py index c492b62f35..deb73a5e66 100644 --- a/src/calibre/ebooks/pdf/html_writer.py +++ b/src/calibre/ebooks/pdf/html_writer.py @@ -745,7 +745,7 @@ def get_page_number_display_map(render_manager, opts, num_pages, log): if not isinstance(result, dict): raise ValueError('Not a dict') except Exception: - log.warn(f'Could not do page number mapping, got unexpected result: {repr(result)}') + log.warn(f'Could not do page number mapping, got unexpected result: {result!r}') else: default_map = {int(k): int(v) for k, v in iteritems(result)} return default_map diff --git a/src/calibre/ebooks/rtf2xml/pict.py b/src/calibre/ebooks/rtf2xml/pict.py index 4be35f44a8..65e0d3458f 100644 --- a/src/calibre/ebooks/rtf2xml/pict.py +++ b/src/calibre/ebooks/rtf2xml/pict.py @@ -77,7 +77,7 @@ class Pict: try: os.mkdir(self.__dir_name) except OSError as msg: - msg = f"{str(msg)}Couldn't make directory '{self.__dir_name}':\n" + msg = f"{msg!s}Couldn't make directory '{self.__dir_name}':\n" raise self.__bug_handler else: if self.__run_level > 1: diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.py b/src/calibre/gui2/catalog/catalog_epub_mobi.py index 6aff0f5af1..2f413f3b24 100644 --- a/src/calibre/gui2/catalog/catalog_epub_mobi.py +++ b/src/calibre/gui2/catalog/catalog_epub_mobi.py @@ -552,7 +552,7 @@ class PluginWidget(QWidget,Ui_Form): if False and self.DEBUG: print('opts_dict') for opt in sorted(opts_dict.keys(), key=sort_key): - print(f' {opt}: {repr(opts_dict[opt])}') + print(f' {opt}: {opts_dict[opt]!r}') return opts_dict def populate_combo_boxes(self): diff --git a/src/calibre/gui2/dialogs/duplicates.py b/src/calibre/gui2/dialogs/duplicates.py index 8d47ffce9c..89defacc9e 100644 --- a/src/calibre/gui2/dialogs/duplicates.py +++ b/src/calibre/gui2/dialogs/duplicates.py @@ -146,7 +146,7 @@ class DuplicatesQuestion(QDialog): for i in range(self.dup_list.topLevelItemCount()): x = self.dup_list.topLevelItem(i) check = '✓' if x.checkState(0) == Qt.CheckState.Checked else '✗' - title = f'{check} {str(x.text(0))}' + title = f'{check} {x.text(0)!s}' dups = [] for child in (x.child(j) for j in range(x.childCount())): dups.append('\t' + str(child.text(0))) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 73aef28b32..ac6146be7b 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -965,7 +965,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): break mi.append(self.db.new_api.get_proxy_metadata(_id)) except Exception as e: - prints(f'TemplateLineEditor: exception fetching metadata: {str(e)}') + prints(f'TemplateLineEditor: exception fetching metadata: {e!s}') mi = None t = TemplateDialog(self, self.s_r_template.text(), mi=mi) t.setWindowTitle(_('Edit search/replace template')) diff --git a/src/calibre/gui2/dialogs/template_line_editor.py b/src/calibre/gui2/dialogs/template_line_editor.py index a8b22ebf45..bace207d23 100644 --- a/src/calibre/gui2/dialogs/template_line_editor.py +++ b/src/calibre/gui2/dialogs/template_line_editor.py @@ -30,7 +30,7 @@ class TemplateLineEditor(QLineEdit): mi.append(db.new_api.get_metadata(_id)) self.mi = mi except Exception as e: - prints(f'TemplateLineEditor: exception fetching metadata: {str(e)}') + prints(f'TemplateLineEditor: exception fetching metadata: {e!s}') self.mi = None self.setClearButtonEnabled(True) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index ab73bac22c..a6fc8267b4 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -682,7 +682,7 @@ class ManageDictionaries(Dialog): # {{{ x.setData(0, Qt.ItemDataRole.FontRole, bf if x is item else None) lc = str(item.parent().data(0, Qt.ItemDataRole.UserRole)) pl = dprefs['preferred_locales'] - pl[lc] = f'{lc}-{str(item.data(0, Qt.ItemDataRole.UserRole))}' + pl[lc] = f'{lc}-{item.data(0, Qt.ItemDataRole.UserRole)!s}' dprefs['preferred_locales'] = pl def init_dictionary(self, item): diff --git a/src/calibre/library/catalogs/epub_mobi.py b/src/calibre/library/catalogs/epub_mobi.py index ad2dc21491..d03b38ced2 100644 --- a/src/calibre/library/catalogs/epub_mobi.py +++ b/src/calibre/library/catalogs/epub_mobi.py @@ -387,7 +387,7 @@ class EPUB_MOBI(CatalogPlugin): 'output_profile', 'prefix_rules', 'preset', 'read_book_marker', 'search_text', 'sort_by', 'sort_descriptions_by_author', 'sync', 'thumb_width', 'use_existing_cover', 'wishlist_tag']: - build_log.append(f' {key}: {repr(opts_dict[key])}') + build_log.append(f' {key}: {opts_dict[key]!r}') if opts.verbose: log('\n'.join(line for line in build_log))