From 41cee6f02dc169536463568576055b115b2f0230 Mon Sep 17 00:00:00 2001 From: un-pogaz <46523284+un-pogaz@users.noreply.github.com> Date: Fri, 24 Jan 2025 11:14:24 +0100 Subject: [PATCH] various whitespace (auto-fix) ruff 'E201,E202,E211,E251,E275' --- recipes/20_minutos.recipe | 2 +- recipes/afr.recipe | 2 +- recipes/bar_and_bench.recipe | 2 +- recipes/benchmark_pl.recipe | 2 +- recipes/calgary_herald.recipe | 2 +- recipes/dagens_industri.recipe | 2 +- recipes/diario_sport.recipe | 2 +- recipes/dilema.recipe | 4 ++-- recipes/dnevnik_cro.recipe | 2 +- recipes/edmonton_journal.recipe | 2 +- recipes/el_correo.recipe | 2 +- recipes/europa_press.recipe | 2 +- recipes/faz_net.recipe | 18 +++++++++--------- recipes/free_inquiry.recipe | 2 +- recipes/github.recipe | 8 ++++---- recipes/ifzm.recipe | 2 +- recipes/il_post.recipe | 2 +- recipes/ilmanifesto.recipe | 4 ++-- recipes/internazionale.recipe | 8 ++++---- recipes/liberation.recipe | 2 +- recipes/montreal_gazette.recipe | 2 +- recipes/ottawa_citizen.recipe | 2 +- recipes/parool.recipe | 2 +- recipes/project_syndicate.recipe | 2 +- recipes/radio_canada.recipe | 2 +- recipes/respekt_magazine.recipe | 2 +- recipes/revista22.recipe | 4 ++-- recipes/scroll.recipe | 2 +- recipes/skeptical_enquirer.recipe | 2 +- recipes/spectator_magazine.recipe | 2 +- recipes/stiintasitehnica.recipe | 2 +- recipes/strange_horizons.recipe | 2 +- recipes/tagesspiegel.recipe | 6 +++--- recipes/theoldie.recipe | 12 ++++++------ recipes/times_online.recipe | 2 +- recipes/tls_mag.recipe | 2 +- recipes/vancouver_province.recipe | 2 +- recipes/vancouver_sun.recipe | 2 +- recipes/volksrant.recipe | 2 +- recipes/windows_star.recipe | 2 +- ruff-strict-pep8.toml | 1 + src/calibre/ebooks/djvu/djvu.py | 2 +- src/calibre/ebooks/djvu/djvubzzdec.py | 2 +- src/calibre/ebooks/pdf/reflow.py | 2 +- src/calibre/gui2/actions/__init__.py | 2 +- src/calibre/gui2/catalog/catalog_epub_mobi.py | 2 +- src/calibre/gui2/dialogs/book_info.py | 2 +- src/calibre/gui2/dialogs/custom_recipes.py | 2 +- src/calibre/gui2/tts/manager.py | 2 +- src/calibre/gui2/tweak_book/ui.py | 2 +- src/calibre/scraper/webengine_backend.py | 2 +- src/calibre/srv/metadata.py | 2 +- src/calibre/utils/opensearch/query.py | 2 +- src/odf/element.py | 2 +- 54 files changed, 78 insertions(+), 77 deletions(-) diff --git a/recipes/20_minutos.recipe b/recipes/20_minutos.recipe index 73698f3390..31c8ac0a76 100644 --- a/recipes/20_minutos.recipe +++ b/recipes/20_minutos.recipe @@ -43,7 +43,7 @@ class AdvancedUserRecipe1294946868(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': ['related-news', 'col']}) remove_tags = [ - dict(name='ol', attrs={'class': ['navigation', ]}), dict(name='span', attrs={'class': ['action']}), dict(name='div', attrs={'class': ['twitter comments-list hidden', 'related-news', 'col', 'photo-gallery', 'photo-gallery side-art-block', 'calendario', 'article-comment', 'postto estirar', 'otras_vinetas estirar', 'kment', 'user-actions']}), dict( name='div', attrs={'id': ['twitter-destacados', 'eco-tabs', 'inner', 'vineta_calendario', 'vinetistas clearfix', 'otras_vinetas estirar', 'MIN1', 'main', 'SUP1', 'INT']}), dict(name='ul', attrs={'class': ['article-user-actions', 'stripped-list']}), dict(name='ul', attrs={'id': ['site-links']}), dict(name='li', attrs={'class': ['puntuacion', 'enviar', 'compartir']}) # noqa: E501 + dict(name='ol', attrs={'class': ['navigation', ]}), dict(name='span', attrs={'class': ['action']}), dict(name='div', attrs={'class': ['twitter comments-list hidden', 'related-news', 'col', 'photo-gallery', 'photo-gallery side-art-block', 'calendario', 'article-comment', 'postto estirar', 'otras_vinetas estirar', 'kment', 'user-actions']}), dict(name='div', attrs={'id': ['twitter-destacados', 'eco-tabs', 'inner', 'vineta_calendario', 'vinetistas clearfix', 'otras_vinetas estirar', 'MIN1', 'main', 'SUP1', 'INT']}), dict(name='ul', attrs={'class': ['article-user-actions', 'stripped-list']}), dict(name='ul', attrs={'id': ['site-links']}), dict(name='li', attrs={'class': ['puntuacion', 'enviar', 'compartir']}) # noqa: E501 ] extra_css = ''' diff --git a/recipes/afr.recipe b/recipes/afr.recipe index 000d83f66a..fc89323751 100644 --- a/recipes/afr.recipe +++ b/recipes/afr.recipe @@ -39,7 +39,7 @@ class afr(BasicNewsRecipe): dict(name=['button', 'aside', 'svg']), ] - remove_tags_after= [ dict(name='aside', attrs={'id':'stickyContainer'})] + remove_tags_after= [dict(name='aside', attrs={'id':'stickyContainer'})] extra_css = ''' #img-cap {font-size:small; text-align:center;} diff --git a/recipes/bar_and_bench.recipe b/recipes/bar_and_bench.recipe index 9fe81716bb..f6ebe248ad 100644 --- a/recipes/bar_and_bench.recipe +++ b/recipes/bar_and_bench.recipe @@ -26,7 +26,7 @@ class bar(BasicNewsRecipe): prefixed_classes( 'text-story-m_story-tags__ story-footer-module__metype__' ), - dict(name = 'svg') + dict(name='svg') ] def preprocess_html(self, soup): diff --git a/recipes/benchmark_pl.recipe b/recipes/benchmark_pl.recipe index e3e0aef637..e187756553 100644 --- a/recipes/benchmark_pl.recipe +++ b/recipes/benchmark_pl.recipe @@ -23,7 +23,7 @@ class BenchmarkPl(BasicNewsRecipe): keep_only_tags = [dict(id=['articleHeader', 'articleGallery']), dict( name='div', attrs={'class': ['m_zwykly', 'gallery']}), dict(id='article')] remove_tags_after = dict(id='article') - remove_tags = [dict(name='div', attrs={'class': ['comments', 'body', 'kategoria', 'socialize', 'thumb', 'panelOcenaObserwowane', 'categoryNextToSocializeGallery', 'breadcrumb', 'footer', 'moreTopics']}), dict(name='table', attrs={ 'background': 'http://www.benchmark.pl/uploads/backend_img/a/fotki_newsy/opinie_dnia/bg.png'}), dict(name='table', attrs={'width': '210', 'cellspacing': '1', 'cellpadding': '4', 'border': '0', 'align': 'right'})] # noqa: E501 + remove_tags = [dict(name='div', attrs={'class': ['comments', 'body', 'kategoria', 'socialize', 'thumb', 'panelOcenaObserwowane', 'categoryNextToSocializeGallery', 'breadcrumb', 'footer', 'moreTopics']}), dict(name='table', attrs={'background': 'http://www.benchmark.pl/uploads/backend_img/a/fotki_newsy/opinie_dnia/bg.png'}), dict(name='table', attrs={'width': '210', 'cellspacing': '1', 'cellpadding': '4', 'border': '0', 'align': 'right'})] # noqa: E501 INDEX = 'http://www.benchmark.pl' feeds = [(u'Aktualnoƛci', u'http://www.benchmark.pl/rss/aktualnosci-pliki.xml'), diff --git a/recipes/calgary_herald.recipe b/recipes/calgary_herald.recipe index 9d68987bf7..01e2f0584d 100644 --- a/recipes/calgary_herald.recipe +++ b/recipes/calgary_herald.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/dagens_industri.recipe b/recipes/dagens_industri.recipe index 12098257dc..570d5d114a 100644 --- a/recipes/dagens_industri.recipe +++ b/recipes/dagens_industri.recipe @@ -21,7 +21,7 @@ class AdvancedUserRecipe1311450855(BasicNewsRecipe): feeds = [(u'DI', u'https://di.se/rss')] - keep_only_tags = [dict(name='h1', attrs={'id': 'ctl00_ExtraWideContentRegion_WideContentRegion_MainRegion_MainContentRegion_MainBodyRegion_headlineNormal'}), dict( name='div', attrs={'id': 'articleBody'})] # noqa: E501 + keep_only_tags = [dict(name='h1', attrs={'id': 'ctl00_ExtraWideContentRegion_WideContentRegion_MainRegion_MainContentRegion_MainBodyRegion_headlineNormal'}), dict(name='div', attrs={'id': 'articleBody'})] # noqa: E501 remove_tags = [ dict(name='div', attrs={'class': 'article-actions clear'}), dict(name='div', attrs={'class': 'article-action-popup'}), dict(name='div', attrs={'class': 'header'}), dict(name='div', attrs={'class': 'content clear'}), dict(name='div', attrs={'id': 'articleAdvertisementDiv'}), dict(name='ul', attrs={'class': 'action-list'}) # noqa: E501 diff --git a/recipes/diario_sport.recipe b/recipes/diario_sport.recipe index c90e60a3f4..e02db71cba 100644 --- a/recipes/diario_sport.recipe +++ b/recipes/diario_sport.recipe @@ -20,7 +20,7 @@ class DiarioSport(BasicNewsRecipe): keep_only_tags = [dict(name='div', attrs={'id': ['noticiasMedio']})] remove_tags = [ - dict(name=['object', 'link', 'script', 'ul']), dict(name='div', attrs={'id': ['scrAdSense', 'herramientas2', 'participacion', 'participacion2', 'bloque1resultados', 'bloque2resultados', 'cont_vinyetesAnt', 'tinta', 'noticiasSuperior', 'cintillopublicidad2']}), dict( name='p', attrs={'class': ['masinformacion', 'hora']}), dict(name='a', attrs={'class': ["'link'"]}), dict(name='div', attrs={'class': ['addthis_toolbox addthis_default_style', 'firma', 'pretitularnoticia']}), dict(name='form', attrs={'id': ['formularioDeBusquedaAvanzada']}) # noqa: E501 + dict(name=['object', 'link', 'script', 'ul']), dict(name='div', attrs={'id': ['scrAdSense', 'herramientas2', 'participacion', 'participacion2', 'bloque1resultados', 'bloque2resultados', 'cont_vinyetesAnt', 'tinta', 'noticiasSuperior', 'cintillopublicidad2']}), dict(name='p', attrs={'class': ['masinformacion', 'hora']}), dict(name='a', attrs={'class': ["'link'"]}), dict(name='div', attrs={'class': ['addthis_toolbox addthis_default_style', 'firma', 'pretitularnoticia']}), dict(name='form', attrs={'id': ['formularioDeBusquedaAvanzada']}) # noqa: E501 ] def preprocess_html(self, soup): diff --git a/recipes/dilema.recipe b/recipes/dilema.recipe index b528696b09..468065ad6c 100644 --- a/recipes/dilema.recipe +++ b/recipes/dilema.recipe @@ -12,8 +12,8 @@ class Volkskrant(BasicNewsRecipe): country = 'RO' category = 'politics, culture, Romania' resolve_internal_links = True - remove_tags_before = { 'class': 'post' } - remove_tags_after = { 'class': 'post_content' } + remove_tags_before = {'class': 'post'} + remove_tags_after = {'class': 'post_content'} remove_tags = [ dict( attrs={ diff --git a/recipes/dnevnik_cro.recipe b/recipes/dnevnik_cro.recipe index 6ace469209..ea9fe20023 100644 --- a/recipes/dnevnik_cro.recipe +++ b/recipes/dnevnik_cro.recipe @@ -59,7 +59,7 @@ class DnevnikCro(BasicNewsRecipe): soup.html['lang'] = self.lang soup.html['dir'] = self.direction - attribs = ['style', 'font', 'valign', 'colspan', 'width', 'height', 'rowspan', 'summary', 'align', 'cellspacing', 'cellpadding', 'frames', 'rules', 'border' ] # noqa: E501 + attribs = ['style', 'font', 'valign', 'colspan', 'width', 'height', 'rowspan', 'summary', 'align', 'cellspacing', 'cellpadding', 'frames', 'rules', 'border'] # noqa: E501 for item in soup.body.findAll(name=['table', 'td', 'tr', 'th', 'caption', 'thead', 'tfoot', 'tbody', 'colgroup', 'col']): item.name = 'div' for attrib in attribs: diff --git a/recipes/edmonton_journal.recipe b/recipes/edmonton_journal.recipe index 27da4b0155..55be31438a 100644 --- a/recipes/edmonton_journal.recipe +++ b/recipes/edmonton_journal.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/el_correo.recipe b/recipes/el_correo.recipe index c364abeee4..675dac2e20 100644 --- a/recipes/el_correo.recipe +++ b/recipes/el_correo.recipe @@ -58,7 +58,7 @@ class elcorreo(BasicNewsRecipe): ] remove_tags = [ - dict(name = ['svg', 'section', 'nav']), + dict(name=['svg', 'section', 'nav']), dict(attrs={'data-voc-component':['dropdown', 'modal', 'slider-grab']}), classes( 'v-mdl-ath__img-c v-adv v-i-b v-mdl-ath__c--2 v-d-cmp-adv v-d-cmp-nws ' diff --git a/recipes/europa_press.recipe b/recipes/europa_press.recipe index a81f142970..7f268d5038 100644 --- a/recipes/europa_press.recipe +++ b/recipes/europa_press.recipe @@ -33,7 +33,7 @@ class AdvancedUserRecipe1294946868(BasicNewsRecipe): remove_tags = [ dict(name='ul', attrs={'id': ['entidadesNoticia', 'MenuSecciones']}), dict(name='div', attrs={'id': ['ImprimirEnviarNoticia', 'PublicidadSuperior', 'CabeceraDerecha', 'Comentarios', 'comentarios full fbConnectAPI', 'ComentarEstaNoticia', 'ctl00_Superior_Main_MasEnChance_cajamasnoticias', 'gl_chn', 'videos_portada_derecha', 'galeria_portada_central', 'galeria_portada_central_boxes']}), dict( # noqa: E501 - name='div', attrs={'class': ['infoRelacionada', 'col_1', 'buscador', 'caja doblecolumna strong', 'CHANCE_EP_Encuesta_frontal text', 'seccionportada col_0', 'seccion header', 'text', 'pie caption_over']}), dict(name='a', attrs={'class': ['buscadorLabel']}), dict(name='span', attrs={'class': ['editado']}), dict(name='table'), dict(name='li') ] # noqa: E501 + name='div', attrs={'class': ['infoRelacionada', 'col_1', 'buscador', 'caja doblecolumna strong', 'CHANCE_EP_Encuesta_frontal text', 'seccionportada col_0', 'seccion header', 'text', 'pie caption_over']}), dict(name='a', attrs={'class': ['buscadorLabel']}), dict(name='span', attrs={'class': ['editado']}), dict(name='table'), dict(name='li')] # noqa: E501 feeds = [ diff --git a/recipes/faz_net.recipe b/recipes/faz_net.recipe index ae78d7a085..2a785e364a 100644 --- a/recipes/faz_net.recipe +++ b/recipes/faz_net.recipe @@ -23,12 +23,12 @@ def format_tickaroo_liveblog(soup): ntag = soup.new_tag('br') tag.insert_before(ntag) - for tag in soup.findAll(class_ = 'tik4-author__wrapper'): - ntag = tag.find(class_ = 'tik4-author__name') + for tag in soup.findAll(class_='tik4-author__wrapper'): + ntag = tag.find(class_='tik4-author__name') if ntag: temp = ntag.extract() temp['class'] = 'tik4-media-body__title' - ntag = tag.find(class_ = 'tik4-author__thumb') + ntag = tag.find(class_='tik4-author__thumb') if ntag and temp: ntag.insert_after(temp) @@ -131,8 +131,8 @@ class FazNet(BasicNewsRecipe): keep_only_tags = [dict(name='article', attrs={'class':['article','storytelling']}), dict(name='body'), dict(name='div', attrs={'class':['imageGallery','image_only']}), - dict(name = 'div', attrs ={'class':'tik4-live__container'}), - dict(name = 'script', attrs = {'id':'__NUXT_DATA__'}), + dict(name='div', attrs={'class':'tik4-live__container'}), + dict(name='script', attrs={'id':'__NUXT_DATA__'}), ] remove_tags = [ @@ -143,7 +143,7 @@ class FazNet(BasicNewsRecipe): 'tik4-by','header-detail__image','mm-adbox','upper-toolbar content-container' ]}), # dict(name ='script'), - dict(name = 'style'), + dict(name='style'), dict(name='svg'), dict(name='div', attrs={'data-module':'teaser'}), @@ -224,14 +224,14 @@ class FazNet(BasicNewsRecipe): tag.unwrap() # remove ":"" - tag = soup.find(class_ ='header-label__content') + tag = soup.find(class_='header-label__content') if tag: - colon=tag.find(class_ ='sr-only') + colon=tag.find(class_='sr-only') if colon: colon.extract() # Skip articles behind paywall - if soup.find(id = 'faz-paywall'): + if soup.find(id='faz-paywall'): self.abort_article('Skipping paywalled article') # Remove F.A.Z. ad diff --git a/recipes/free_inquiry.recipe b/recipes/free_inquiry.recipe index 882b8f5c67..071b071a4b 100644 --- a/recipes/free_inquiry.recipe +++ b/recipes/free_inquiry.recipe @@ -76,7 +76,7 @@ class FreeInquiry(BasicNewsRecipe): url = '' seen.add(url) self.log('Found article:', art_title) - yield{ + yield { 'title': art_title, 'url': url, 'description': desc diff --git a/recipes/github.recipe b/recipes/github.recipe index 1024624ffc..6eae771bd6 100644 --- a/recipes/github.recipe +++ b/recipes/github.recipe @@ -13,13 +13,13 @@ class GithubBlog(BasicNewsRecipe): oldest_article = 14 keep_only_tags = [ - dict(name='div', attrs={'class': 'col-12 offset-lg-1 col-lg-10 col-xl-7 mt-5 mt-lg-10 mb-6 mb-lg-8' }), - dict(name='section', attrs={'class': lambda x: x and 'post__content' in x.split(' ') }) + dict(name='div', attrs={'class': 'col-12 offset-lg-1 col-lg-10 col-xl-7 mt-5 mt-lg-10 mb-6 mb-lg-8'}), + dict(name='section', attrs={'class': lambda x: x and 'post__content' in x.split(' ')}) ] remove_tags = [ - dict(name='div', attrs={'class': lambda x: x and 'post-tags' in x.split(' ') }), - dict(name='ul', attrs={'class': lambda x: x and 'post-hero__categories' in x.split(' ') }) + dict(name='div', attrs={'class': lambda x: x and 'post-tags' in x.split(' ')}), + dict(name='ul', attrs={'class': lambda x: x and 'post-hero__categories' in x.split(' ')}) ] preprocess_regexps = [ diff --git a/recipes/ifzm.recipe b/recipes/ifzm.recipe index 0ceacd4dc0..74fef36032 100644 --- a/recipes/ifzm.recipe +++ b/recipes/ifzm.recipe @@ -45,7 +45,7 @@ class infzm(BasicNewsRecipe): # if article is paywalled, add code to figure out machine_id raw = br.open(res_link).read() html = json_to_html(raw, link) - return ({ 'data': html, 'url': link }) + return ({'data': html, 'url': link}) extra_css = ''' img {display:block; margin:0 auto;} diff --git a/recipes/il_post.recipe b/recipes/il_post.recipe index cd45d211b4..3297ca3de7 100644 --- a/recipes/il_post.recipe +++ b/recipes/il_post.recipe @@ -14,7 +14,7 @@ from datetime import date, timedelta from calibre.web.feeds.news import BasicNewsRecipe -dates = [ date.today().strftime('%Y/%m/%d'), (date.today() - timedelta(1)).strftime('%Y/%m/%d') ] +dates = [date.today().strftime('%Y/%m/%d'), (date.today() - timedelta(1)).strftime('%Y/%m/%d')] # ----------- CUSTOMIZATION OPTIONS START ----------- diff --git a/recipes/ilmanifesto.recipe b/recipes/ilmanifesto.recipe index 5270490774..e39ce9bf74 100644 --- a/recipes/ilmanifesto.recipe +++ b/recipes/ilmanifesto.recipe @@ -34,7 +34,7 @@ class IlManifesto(BasicNewsRecipe): startSoup = self.index_to_soup(startUrl) lastEdition = startSoup.findAll('div', id='accordion_inedicola')[ 1].find('a')['href'] - del(startSoup) + del (startSoup) self.manifesto_index = MANIFESTO_BASEURL + lastEdition urlsplit = lastEdition.split('/') self.manifesto_datestr = urlsplit[-1] @@ -106,5 +106,5 @@ class IlManifesto(BasicNewsRecipe): summary = sommNode template = "%(title)s

%(title)s

%(subtitle)s

%(author)s

%(summary)s
%(content)s
" # noqa: E501 - del(bs) + del (bs) return template % dict(title=title, subtitle=subtitle, author=author, summary=summary, content=content) diff --git a/recipes/internazionale.recipe b/recipes/internazionale.recipe index 19540caf93..052f3519d7 100644 --- a/recipes/internazionale.recipe +++ b/recipes/internazionale.recipe @@ -12,8 +12,8 @@ class Volkskrant(BasicNewsRecipe): country = 'IT' category = 'news, politics, Italy, world' resolve_internal_links = True - remove_tags_before = { 'name': 'article' } - remove_tags_after = { 'name': 'article' } + remove_tags_before = {'name': 'article'} + remove_tags_after = {'name': 'article'} remove_tags = [ dict( attrs={ @@ -67,8 +67,8 @@ class Volkskrant(BasicNewsRecipe): def parse_index(self): soup = self.index_to_soup(self.current_number_url) - self.cover_url = soup.find('span', { 'class': 'img_expand' })['data-src'] - main_container = soup.find('div', { 'class': 'content_data' }) + self.cover_url = soup.find('span', {'class': 'img_expand'})['data-src'] + main_container = soup.find('div', {'class': 'content_data'}) children = main_container.findAll('div', recursive=False) sections = [] current_section = None diff --git a/recipes/liberation.recipe b/recipes/liberation.recipe index d94dc4c0ec..9015eb0866 100644 --- a/recipes/liberation.recipe +++ b/recipes/liberation.recipe @@ -150,7 +150,7 @@ class Liberation(BasicNewsRecipe): } api = 'https://arc.api.liberation.fr/content/v4/?' + urlencode(query, safe='()!', quote_via=quote) rq = Request( - url= api, + url=api, headers=headers ) raw = br.open(rq).read() diff --git a/recipes/montreal_gazette.recipe b/recipes/montreal_gazette.recipe index de0c5f0d9a..1ae5c6743a 100644 --- a/recipes/montreal_gazette.recipe +++ b/recipes/montreal_gazette.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/ottawa_citizen.recipe b/recipes/ottawa_citizen.recipe index 074913c484..68342217d5 100644 --- a/recipes/ottawa_citizen.recipe +++ b/recipes/ottawa_citizen.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/parool.recipe b/recipes/parool.recipe index 9fea4d9d8d..3c2ef05987 100644 --- a/recipes/parool.recipe +++ b/recipes/parool.recipe @@ -50,7 +50,7 @@ class Parool(BasicNewsRecipe): teaser_label = self.tag_to_string(header.find('h4').find('span', attrs={'class': 'teaser__label'})).strip() teaser_sublabel = self.tag_to_string(header.find('h4').find('span', attrs={'class': 'teaser__sublabel'})).strip() teaser_title = self.tag_to_string(header.find('h3').find('span', attrs={'class': 'teaser__title__value--short'})).strip() - ignore = { 'dirkjan', 's1ngle', 'pukkels', 'hein de kort' } + ignore = {'dirkjan', 's1ngle', 'pukkels', 'hein de kort'} if teaser_label.lower() in ignore: continue parts = [] diff --git a/recipes/project_syndicate.recipe b/recipes/project_syndicate.recipe index c44114e424..9305be77fb 100644 --- a/recipes/project_syndicate.recipe +++ b/recipes/project_syndicate.recipe @@ -60,7 +60,7 @@ class projectsynd(BasicNewsRecipe): keep_only_tags = [ dict(attrs={'itemprop':lambda x: x and 'associatedMedia' in x.split()}), dict(attrs={'itemprop':['headline', 'datePublished', 'author', 'abstract', 'articleBody']}), - dict(name = 'aside', attrs={'data-page-area':'article-bottom'}) + dict(name='aside', attrs={'data-page-area':'article-bottom'}) ] remove_tags = [ diff --git a/recipes/radio_canada.recipe b/recipes/radio_canada.recipe index dfe2235c04..1138635a46 100644 --- a/recipes/radio_canada.recipe +++ b/recipes/radio_canada.recipe @@ -152,7 +152,7 @@ class RadioCanada(BasicNewsRecipe): # The following was copied and adapted as per the following post: # https://www.mobileread.com/forums/showpost.php?p=1165462&postcount=6 # Credit goes to user Starson17 - def parse_feeds (self): + def parse_feeds(self): feeds = BasicNewsRecipe.parse_feeds(self) for feed in feeds: for article in feed.articles[:]: diff --git a/recipes/respekt_magazine.recipe b/recipes/respekt_magazine.recipe index 13f3cf7212..1325aabb11 100644 --- a/recipes/respekt_magazine.recipe +++ b/recipes/respekt_magazine.recipe @@ -171,4 +171,4 @@ class respektRecipe(BasicNewsRecipe): o.getparent().replace(o,e) except: pass - return(BeautifulSoup(lxml.etree.tostring(root,encoding='unicode'))) + return (BeautifulSoup(lxml.etree.tostring(root,encoding='unicode'))) diff --git a/recipes/revista22.recipe b/recipes/revista22.recipe index 9fe631e7e2..ab64418538 100644 --- a/recipes/revista22.recipe +++ b/recipes/revista22.recipe @@ -12,8 +12,8 @@ class Volkskrant(BasicNewsRecipe): country = 'RO' category = 'news, politics, Romania' resolve_internal_links = True - remove_tags_before = { 'class': 'col-span-8' } - remove_tags_after = { 'class': 'col-span-8' } + remove_tags_before = {'class': 'col-span-8'} + remove_tags_after = {'class': 'col-span-8'} remove_tags = [ dict( attrs={ diff --git a/recipes/scroll.recipe b/recipes/scroll.recipe index ee012d32f8..c1cef82bfd 100644 --- a/recipes/scroll.recipe +++ b/recipes/scroll.recipe @@ -25,7 +25,7 @@ class scroll(BasicNewsRecipe): ''' keep_only_tags = [ - dict(name = 'header'), + dict(name='header'), classes('featured-image article-body') ] diff --git a/recipes/skeptical_enquirer.recipe b/recipes/skeptical_enquirer.recipe index d3cce85add..d4ac25b16c 100644 --- a/recipes/skeptical_enquirer.recipe +++ b/recipes/skeptical_enquirer.recipe @@ -76,7 +76,7 @@ class FreeInquiry(BasicNewsRecipe): url = '' seen.add(url) self.log('Found article:', art_title) - yield{ + yield { 'title': art_title, 'url': url, 'description': desc diff --git a/recipes/spectator_magazine.recipe b/recipes/spectator_magazine.recipe index 7090eff021..e40b4bc297 100644 --- a/recipes/spectator_magazine.recipe +++ b/recipes/spectator_magazine.recipe @@ -37,7 +37,7 @@ class spectator(BasicNewsRecipe): ] remove_tags = [ - dict(name = ['svg', 'button']), + dict(name=['svg', 'button']), classes( 'entry-meta audio-read-block insert--most-popular ad-slot ad-slot--in-content ad-content ' 'subscription-banner ' diff --git a/recipes/stiintasitehnica.recipe b/recipes/stiintasitehnica.recipe index e476b0d22d..39cc2c90a4 100644 --- a/recipes/stiintasitehnica.recipe +++ b/recipes/stiintasitehnica.recipe @@ -33,7 +33,7 @@ class Stiintasitehnica(BasicNewsRecipe): ] remove_tags = [ - dict(name='span', attrs={'class': ['redEar']}), dict(name='table', attrs={'class': ['connect_widget_interactive_area']}), dict(name='div', attrs={'class': ['panel-overlay']}), dict(name='div', attrs={ 'id': ['pointer']}), dict(name='img', attrs={'class': ['nav-next', 'nav-prev']}), dict(name='table', attrs={'class': ['connect_widget_interactive_area']}), dict(name='hr', attrs={'class': ['dotted']}) # noqa: E501 + dict(name='span', attrs={'class': ['redEar']}), dict(name='table', attrs={'class': ['connect_widget_interactive_area']}), dict(name='div', attrs={'class': ['panel-overlay']}), dict(name='div', attrs={'id': ['pointer']}), dict(name='img', attrs={'class': ['nav-next', 'nav-prev']}), dict(name='table', attrs={'class': ['connect_widget_interactive_area']}), dict(name='hr', attrs={'class': ['dotted']}) # noqa: E501 ] remove_tags_after = [ diff --git a/recipes/strange_horizons.recipe b/recipes/strange_horizons.recipe index 44b5c847f8..7652ce6cc7 100644 --- a/recipes/strange_horizons.recipe +++ b/recipes/strange_horizons.recipe @@ -28,7 +28,7 @@ class StrangeHorizons(BasicNewsRecipe): ] remove_tags = [ - dict(name = 'button'), + dict(name='button'), classes('font-size sharedaddy comments-form-row') ] diff --git a/recipes/tagesspiegel.recipe b/recipes/tagesspiegel.recipe index 7a36a1059c..3f66604571 100644 --- a/recipes/tagesspiegel.recipe +++ b/recipes/tagesspiegel.recipe @@ -50,12 +50,12 @@ class TagesspiegelRss(BasicNewsRecipe): return cover keep_only_tags = [ - dict(name = 'header', attrs={'class':'Bo'}), - dict(name = 'div', attrs={'id':'story-elements'}) + dict(name='header', attrs={'class':'Bo'}), + dict(name='div', attrs={'id':'story-elements'}) ] remove_tags = [ - dict(name = 'aside'), + dict(name='aside'), classes('iqd_mainAd Bs') ] diff --git a/recipes/theoldie.recipe b/recipes/theoldie.recipe index ef5bf5a776..eb1cfac995 100644 --- a/recipes/theoldie.recipe +++ b/recipes/theoldie.recipe @@ -119,9 +119,9 @@ class PrivateEyeRecipe(BasicNewsRecipe): for h in a.findAll('h3'): (title, author) = self.title_author(h.getText()) content_articles.append(self.article_entry( - title = title, - url = self.abs_url(a.get('href')), - author = author, + title=title, + url=self.abs_url(a.get('href')), + author=author, )) break else: @@ -157,9 +157,9 @@ class PrivateEyeRecipe(BasicNewsRecipe): else: (title, author) = self.title_author(a.getText()) articles.append(self.article_entry( - title = title, - url = self.abs_url(a.get('href')), - author = author, + title=title, + url=self.abs_url(a.get('href')), + author=author, )) if not articles: diff --git a/recipes/times_online.recipe b/recipes/times_online.recipe index 23c28ab071..ce52947388 100644 --- a/recipes/times_online.recipe +++ b/recipes/times_online.recipe @@ -65,7 +65,7 @@ class times(BasicNewsRecipe): ] remove_tags_after = [ - dict(name = 'div', attrs={'id':'paywall-portal-article-footer'}) + dict(name='div', attrs={'id':'paywall-portal-article-footer'}) ] def preprocess_html(self, soup): diff --git a/recipes/tls_mag.recipe b/recipes/tls_mag.recipe index 1be3472516..5f94a1094c 100644 --- a/recipes/tls_mag.recipe +++ b/recipes/tls_mag.recipe @@ -92,7 +92,7 @@ class TLS(BasicNewsRecipe): if x['byline']['text']: desc = 'By ' + re_html(x['byline']['text']) + ' | ' + desc self.log(' ', title, '\n\t', desc, '\n\t', url) - return ({ 'title': title, 'description': desc, 'url': url }) + return ({'title': title, 'description': desc, 'url': url}) def preprocess_html(self, soup): for img in soup.findAll('img', attrs={'src':True}): diff --git a/recipes/vancouver_province.recipe b/recipes/vancouver_province.recipe index 40b848e848..473156ebc5 100644 --- a/recipes/vancouver_province.recipe +++ b/recipes/vancouver_province.recipe @@ -227,7 +227,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/vancouver_sun.recipe b/recipes/vancouver_sun.recipe index e06a0a3492..c66cac483a 100644 --- a/recipes/vancouver_sun.recipe +++ b/recipes/vancouver_sun.recipe @@ -215,7 +215,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/volksrant.recipe b/recipes/volksrant.recipe index c6cd3d6779..2b86535dbf 100644 --- a/recipes/volksrant.recipe +++ b/recipes/volksrant.recipe @@ -104,7 +104,7 @@ class Volkskrant(BasicNewsRecipe): if tag.name == 'picture': tag.replaceWith(tag.find('img')) - comic_articles = { 'Bas van der Schot', 'Poldermodellen', 'Gummbah', 'Sigmund' } + comic_articles = {'Bas van der Schot', 'Poldermodellen', 'Gummbah', 'Sigmund'} if self.tag_to_string(soup.find('h1')).strip() in comic_articles: for node in soup.find('figure').find_next_siblings(): node.extract() diff --git a/recipes/windows_star.recipe b/recipes/windows_star.recipe index dd6547a4fb..7694b50a1a 100644 --- a/recipes/windows_star.recipe +++ b/recipes/windows_star.recipe @@ -57,7 +57,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del(div['id']) + del (div['id']) return soup def parse_index(self): diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml index cea7e295ea..2cd1a8c895 100644 --- a/ruff-strict-pep8.toml +++ b/ruff-strict-pep8.toml @@ -39,6 +39,7 @@ select = [ 'E302', 'E303', 'E304', 'E305', 'W391', # blank-line standard 'E111', 'E112', 'E113', 'E117', # code indentation 'E114', 'E115', 'E116', 'E261', 'E262', 'E265', # comment formating + 'E201', 'E202', 'E211', 'E251', 'E275', # various whitespace ] unfixable = ['PIE794'] diff --git a/src/calibre/ebooks/djvu/djvu.py b/src/calibre/ebooks/djvu/djvu.py index a071517983..9ce34f9514 100644 --- a/src/calibre/ebooks/djvu/djvu.py +++ b/src/calibre/ebooks/djvu/djvu.py @@ -109,7 +109,7 @@ class DJVUFile: def __init__(self, instream, verbose=0): self.instream = instream buf = self.instream.read(4) - assert(buf == b'AT&T') + assert (buf == b'AT&T') buf = self.instream.read() self.dc = DjvuChunk(buf, 0, len(buf), verbose=verbose) diff --git a/src/calibre/ebooks/djvu/djvubzzdec.py b/src/calibre/ebooks/djvu/djvubzzdec.py index f850094fe4..6056e9dd72 100644 --- a/src/calibre/ebooks/djvu/djvubzzdec.py +++ b/src/calibre/ebooks/djvu/djvubzzdec.py @@ -416,7 +416,7 @@ class BZZDecoder: # Create machine independent ffz table for i in range(256): j = i - while(j & 0x80): + while (j & 0x80): self.ffzt[i] += 1 j <<= 1 # Initialize table diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py index 6f9bb2b545..342a2a0957 100644 --- a/src/calibre/ebooks/pdf/reflow.py +++ b/src/calibre/ebooks/pdf/reflow.py @@ -306,7 +306,7 @@ class Text(Element): if not (self.text_as_string.endswith(' ') \ or self.text_as_string.endswith('-') \ or other.text_as_string.startswith(' ') \ - or other.text_as_string.startswith('-') ): + or other.text_as_string.startswith('-')): has_gap = 1 else: has_gap = 0 diff --git a/src/calibre/gui2/actions/__init__.py b/src/calibre/gui2/actions/__init__.py index 0b18ce5b00..59c119f346 100644 --- a/src/calibre/gui2/actions/__init__.py +++ b/src/calibre/gui2/actions/__init__.py @@ -31,7 +31,7 @@ def toolbar_widgets_for_action(gui, action): # The button might be hidden if not w.isVisible(): continue - yield(w) + yield (w) except Exception: continue diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.py b/src/calibre/gui2/catalog/catalog_epub_mobi.py index e23acfdb57..3cf42b91e3 100644 --- a/src/calibre/gui2/catalog/catalog_epub_mobi.py +++ b/src/calibre/gui2/catalog/catalog_epub_mobi.py @@ -725,7 +725,7 @@ class PluginWidget(QWidget,Ui_Form): self.preset_field.setCurrentIndex(0) if item_name in self.presets.keys(): - del(self.presets[item_name]) + del (self.presets[item_name]) self.presets.commit() def preset_save(self): diff --git a/src/calibre/gui2/dialogs/book_info.py b/src/calibre/gui2/dialogs/book_info.py index 5a25abd8bb..7a00837bd9 100644 --- a/src/calibre/gui2/dialogs/book_info.py +++ b/src/calibre/gui2/dialogs/book_info.py @@ -206,7 +206,7 @@ class BookInfo(QDialog, DropMixin): self.details = Details(parent.book_details.book_info, self, allow_context_menu=library_path is None, - is_locked = dialog_number == DialogNumbers.Locked) + is_locked=dialog_number == DialogNumbers.Locked) self.details.anchor_clicked.connect(self.on_link_clicked) self.link_delegate = link_delegate self.details.setAttribute(Qt.WidgetAttribute.WA_OpaquePaintEvent, False) diff --git a/src/calibre/gui2/dialogs/custom_recipes.py b/src/calibre/gui2/dialogs/custom_recipes.py index 890fd7e1fb..c72d94f49c 100644 --- a/src/calibre/gui2/dialogs/custom_recipes.py +++ b/src/calibre/gui2/dialogs/custom_recipes.py @@ -488,7 +488,7 @@ class AdvancedRecipe(QWidget): # {{{ compile_recipe(src) except Exception as err: error_dialog(self, _('Invalid recipe'), _( - 'Failed to compile the recipe, with syntax error: {}' ).format(err), show=True) + 'Failed to compile the recipe, with syntax error: {}').format(err), show=True) return False return True diff --git a/src/calibre/gui2/tts/manager.py b/src/calibre/gui2/tts/manager.py index cb3c5a889d..78ce3f8c7a 100644 --- a/src/calibre/gui2/tts/manager.py +++ b/src/calibre/gui2/tts/manager.py @@ -40,7 +40,7 @@ class Tracker: self.last_pos = 0 self.queue: deque[Utterance] = deque() - def parse_marked_text(self, marked_text, limit = MAX_UTTERANCE_LENGTH): + def parse_marked_text(self, marked_text, limit=MAX_UTTERANCE_LENGTH): self.clear() text = [] text_len = chunk_len = index_in_positions = offset_in_text = 0 diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 2c8bc5a208..0686096c16 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -401,7 +401,7 @@ class Main(MainWindow): self.action_save.setEnabled(False) self.action_save_copy = treg('save.png', _('Save a ©'), self.boss.save_copy, 'save-copy', 'Ctrl+Alt+S', _('Save a copy of the book')) self.action_save_copy_edit = treg('save.png', _('Save a © and edit in new window'), partial(self.boss._save_copy, 'edit'), 'save-copy-edit', - 'Ctrl+Shift+S', _( 'Save a copy of the book and edit it in a new window')) + 'Ctrl+Shift+S', _('Save a copy of the book and edit it in a new window')) self.action_save_copy_replace = treg('save.png', _('Save a © and edit here'), partial(self.boss._save_copy, 'replace'), 'save-copy-replace', 'Ctrl+Alt+Shift+S', _('Save a copy of the book and edit it in this window')) self.action_quit = treg('window-close.png', _('&Quit'), self.boss.quit, 'quit', 'Ctrl+Q', _('Quit')) diff --git a/src/calibre/scraper/webengine_backend.py b/src/calibre/scraper/webengine_backend.py index 6200ec250a..3e736d82bd 100644 --- a/src/calibre/scraper/webengine_backend.py +++ b/src/calibre/scraper/webengine_backend.py @@ -124,7 +124,7 @@ class Worker(QWebEnginePage): if not sip.isdeleted(self): self.messages_dispatch.emit(messages) - def runjs(self, js: str, callback = None) -> None: + def runjs(self, js: str, callback=None) -> None: if callback is None: self.runJavaScript(js, QWebEngineScript.ScriptWorldId.ApplicationWorld) else: diff --git a/src/calibre/srv/metadata.py b/src/calibre/srv/metadata.py index 2ab6fe2a9f..2c52bef5a5 100644 --- a/src/calibre/srv/metadata.py +++ b/src/calibre/srv/metadata.py @@ -157,7 +157,7 @@ def category_item_as_json(x, clear_rating=False): return ans -def get_gpref(name: str, defval = None): +def get_gpref(name: str, defval=None): gprefs = getattr(get_gpref, 'gprefs', None) if gprefs is None: from calibre.utils.config import JSONConfig diff --git a/src/calibre/utils/opensearch/query.py b/src/calibre/utils/opensearch/query.py index 94d5cb77bf..ba64fbfa2e 100644 --- a/src/calibre/utils/opensearch/query.py +++ b/src/calibre/utils/opensearch/query.py @@ -56,7 +56,7 @@ class Query: query_string[name] = [getattr(self, macro)] else: # remove the name/value pair - del(query_string[name]) + del (query_string[name]) # copy the url parts and substitute in our new query string url_parts = list(self.url_parts) diff --git a/src/odf/element.py b/src/odf/element.py index 14794d21fa..8a71b72623 100644 --- a/src/odf/element.py +++ b/src/odf/element.py @@ -299,7 +299,7 @@ class Element(Node): def __init__(self, attributes=None, text=None, cdata=None, qname=None, qattributes=None, check_grammar=True, **args): if qname is not None: self.qname = qname - assert(hasattr(self, 'qname')) + assert (hasattr(self, 'qname')) self.ownerDocument = None self.childNodes=[] self.allowed_children = grammar.allowed_children.get(self.qname)