explicit f-string conversion (auto-fix)

ruff 'RUF010'
This commit is contained in:
un-pogaz 2025-01-24 11:14:20 +01:00
parent 537ea5ef34
commit 5edc9b814c
16 changed files with 21 additions and 21 deletions

View File

@ -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

View File

@ -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):
</html>
'''
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

View File

@ -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

View File

@ -252,7 +252,7 @@ fragment ArticlePageFields on Article {
</span>
</div>
{lede_image_html}
{str(body_soup)}
{body_soup!s}
{author_bios_html}
</article>
</body></html>'''

View File

@ -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',

View File

@ -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

View File

@ -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

View File

@ -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 = []

View File

@ -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

View File

@ -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:

View File

@ -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):

View File

@ -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)))

View File

@ -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'))

View File

@ -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)

View File

@ -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):

View File

@ -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))