From ddd580c85cab1f87d25cb81a0311db63264664b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 27 Jan 2025 10:26:01 +0530 Subject: [PATCH] Remove more exclusions --- pyproject.toml | 5 --- setup/check.py | 2 +- setup/commands.py | 63 +++++++++++++++++++++++------- src/calibre/customize/__init__.py | 2 +- src/calibre/devices/interface.py | 4 +- src/calibre/utils/smartypants.py | 64 +++++++++++++++---------------- src/calibre/web/feeds/news.py | 2 +- 7 files changed, 87 insertions(+), 55 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6d7ddbc87b..958d77790a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,10 +49,7 @@ unfixable = ['PIE794', 'ISC001'] "recipes/*" = ['UP'] "manual/plugin_examples/*" = ['UP'] "setup/changelog.py" = ['ISC001'] -"setup/commands.py" = ['RUF022'] "src/calibre/*" = ['UP031'] -"src/calibre/customize/__init__.py" = ['RET501'] -"src/calibre/devices/interface.py" = ['RET501'] "src/calibre/devices/kobo/driver.py" = ['E116'] "src/calibre/ebooks/unihandecode/*codepoints.py" = ['E501'] "src/calibre/ebooks/metadata/sources/*" = ['UP'] @@ -61,8 +58,6 @@ unfixable = ['PIE794', 'ISC001'] "src/calibre/gui2/store/stores/*" = ['UP'] "src/calibre/gui2/tts/manager.py" = ['UP037'] "src/calibre/utils/copy_files.py" = ['UP037'] -"src/calibre/utils/smartypants.py" = ['RUF055'] -"src/calibre/web/feeds/news.py" = ['RET501'] "src/qt/*.py" = ['I', 'E302'] "src/qt/*.pyi" = ['I'] diff --git a/setup/check.py b/setup/check.py index 18a34f0e34..c4bed18298 100644 --- a/setup/check.py +++ b/setup/check.py @@ -11,7 +11,7 @@ import json import os import subprocess -from setup import Command, build_cache_dir, dump_json, edit_file, require_clean_git, require_git_master +from setup import Command, build_cache_dir, dump_json, edit_file class Message: diff --git a/setup/commands.py b/setup/commands.py index 8cabf34635..fa03ad7a9e 100644 --- a/setup/commands.py +++ b/setup/commands.py @@ -6,21 +6,58 @@ __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' __all__ = [ - 'pot', 'translations', 'get_translations', 'iso_data', 'iso639', 'iso3166', - 'build', 'mathjax', 'man_pages', - 'gui', + 'bootstrap', + 'build', + 'build_dep', + 'cacerts', + 'check', + 'develop', + 'export_packages', + 'extdev', + 'get_translations', 'git_version', - 'develop', 'install', - 'rapydscript', 'cacerts', 'recent_uas', 'resources', - 'check', 'test', 'test_rs', 'upgrade_source_code', - 'sdist', 'bootstrap', 'extdev', - 'manual', 'tag_release', - 'upload_to_server', + 'gui', + 'hyphenation', + 'install', + 'iso639', + 'iso3166', + 'iso_data', + 'liberation_fonts', + 'linux', + 'linux64', + 'linuxarm64', + 'man_pages', + 'manual', + 'mathjax', + 'osx', + 'piper_voices', + 'pot', + 'publish', + 'publish_betas', + 'publish_preview', + 'rapydscript', + 'recent_uas', + 'resources', + 'reupload', + 'sdist', + 'stage1', + 'stage2', + 'stage3', + 'stage4', + 'stage5', + 'stylelint', + 'tag_release', + 'test', + 'test_rs', + 'translations', + 'upgrade_source_code', + 'upload_demo', 'upload_installers', - 'upload_user_manual', 'upload_demo', 'reupload', - 'stage1', 'stage2', 'stage3', 'stage4', 'stage5', 'publish', 'publish_betas', 'publish_preview', - 'linux', 'linux64', 'linuxarm64', 'win', 'win64', 'osx', 'build_dep', - 'export_packages', 'hyphenation', 'piper_voices', 'liberation_fonts', 'stylelint', 'xwin', + 'upload_to_server', + 'upload_user_manual', + 'win', + 'win64', + 'xwin', ] from setup.installers import OSX, BuildDep, ExportPackages, ExtDev, Linux, Linux64, LinuxArm64, Win, Win64 diff --git a/src/calibre/customize/__init__.py b/src/calibre/customize/__init__.py index df0b6a6759..7769ae5ea7 100644 --- a/src/calibre/customize/__init__.py +++ b/src/calibre/customize/__init__.py @@ -474,7 +474,7 @@ class MetadataReaderPlugin(Plugin): # {{{ in :attr:`file_types`. :return: A :class:`calibre.ebooks.metadata.book.Metadata` object ''' - return None + return # }}} diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index e8f69f575e..22de6f5740 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -138,7 +138,7 @@ class DevicePlugin(Plugin): @classmethod def get_open_popup_message(self): ' GUI displays this as a non-modal popup. Should be an instance of OpenPopupMessage ' - return None + return # Device detection {{{ def test_bcd(self, bcdDevice, bcd): @@ -631,7 +631,7 @@ class DevicePlugin(Plugin): This method can be called on the GUI thread. A driver that implements this method must be thread safe. ''' - return None + return def start_plugin(self): ''' diff --git a/src/calibre/utils/smartypants.py b/src/calibre/utils/smartypants.py index 3a5d72facd..4336bf0864 100644 --- a/src/calibre/utils/smartypants.py +++ b/src/calibre/utils/smartypants.py @@ -493,7 +493,7 @@ def smartyPants(text, attr='1'): if not in_pre: t = processEscapes(t) - t = re.sub(r'"', '"', t) + t = t.replace('"', '"') t = dashes_func(t) t = ellipses_func(t) # Note: backticks need to be processed before quotes. @@ -548,10 +548,10 @@ def educateQuotes(text): text = re.sub(r''''"(?=\w)''', '''‘“''', text) text = re.sub(r'''""(?=\w)''', '''““''', text) text = re.sub(r'''''(?=\w)''', '''‘‘''', text) - text = re.sub(r'''\"\'''', '''”’''', text) - text = re.sub(r'''\'\"''', '''’”''', text) - text = re.sub(r'''""''', '''””''', text) - text = re.sub(r"""''""", '''’’''', text) + text = text.replace('"\'', '”’') + text = text.replace('\'"', '''’”''') + text = text.replace('""', '””') + text = text.replace(r"""''""", '''’’''') # Special case for decade abbreviations (the '80s --> ’80s): # See http://practicaltypography.com/apostrophes.html @@ -612,7 +612,7 @@ def educateQuotes(text): text = closing_single_quotes_regex.sub(r'''\1’\2''', text) # Any remaining single quotes should be opening ones: - text = re.sub(r"""'""", r'''‘''', text) + text = text.replace("'", '‘') # Get most opening double quotes: opening_double_quotes_regex = re.compile(r''' @@ -648,7 +648,7 @@ def educateQuotes(text): text = text[:-1] + '”' # Any remaining quotes should be opening ones. - text = re.sub(r'"', r'''“''', text) + text = text.replace('"', '“') return text @@ -662,8 +662,8 @@ def educateBackticks(text): Example output: “Isn't this fun?” ''' - text = re.sub(r'''``''', r'''“''', text) - text = re.sub(r"""''""", r'''”''', text) + text = text.replace('``', '“') + text = text.replace("''", '”') return text @@ -677,8 +677,8 @@ def educateSingleBackticks(text): Example output: ‘Isn’t this fun?’ ''' - text = re.sub(r'''`''', r'''‘''', text) - text = re.sub(r"""'""", r'''’''', text) + text = text.replace('`', '‘') + text = text.replace("'", '’') return text @@ -690,8 +690,8 @@ def educateDashes(text): an em-dash HTML entity. ''' - text = re.sub(r'''---''', r'''–''', text) # en (yes, backwards) - text = re.sub(r'''--''', r'''—''', text) # em (yes, backwards) + text = text.replace('---', '–') # en (yes, backwards) + text = text.replace('--', '—') # em (yes, backwards) return text @@ -704,8 +704,8 @@ def educateDashesOldSchool(text): an em-dash HTML entity. ''' - text = re.sub(r'''---''', r'''—''', text) # em (yes, backwards) - text = re.sub(r'''--''', r'''–''', text) # en (yes, backwards) + text = text.replace('---', '—') # em (yes, backwards) + text = text.replace('--', '–') # en (yes, backwards) return text @@ -724,8 +724,8 @@ def educateDashesOldSchoolInverted(text): the shortcut should be shorter to type. (Thanks to Aaron Swartz for the idea.) ''' - text = re.sub(r'''---''', r'''–''', text) # em - text = re.sub(r'''--''', r'''—''', text) # en + text = text.replace('---', '–') # em + text = text.replace('--', '—') # en return text @@ -739,8 +739,8 @@ def educateEllipses(text): Example output: Huh…? ''' - text = re.sub(r'''\.\.\.''', r'''…''', text) - text = re.sub(r'''\. \. \.''', r'''…''', text) + text = text.replace('...', '…') + text = text.replace('. . .', '…') return text @@ -754,16 +754,16 @@ def stupefyEntities(text): Example output: "Hello -- world." ''' - text = re.sub(r'''–''', r'''-''', text) # en-dash - text = re.sub(r'''—''', r'''--''', text) # em-dash + text = text.replace('–', '-') # en-dash + text = text.replace('—', '--') # em-dash - text = re.sub(r'''‘''', r"""'""", text) # open single quote - text = re.sub(r'''’''', r"""'""", text) # close single quote + text = text.replace('‘', "'") # open single quote + text = text.replace('’', "'") # close single quote - text = re.sub(r'''“''', r'''"''', text) # open double quote - text = re.sub(r'''”''', r'''"''', text) # close double quote + text = text.replace('“', '"') # open double quote + text = text.replace('”', '"') # close double quote - text = re.sub(r'''…''', r'''...''', text) # ellipsis + text = text.replace('…', '...') # ellipsis return text @@ -784,12 +784,12 @@ def processEscapes(text): \- - \` ` ''' - text = re.sub(r'''\\\\''', r'''\''', text) - text = re.sub(r'''\\"''', r'''"''', text) - text = re.sub(r"""\\'""", r''''''', text) - text = re.sub(r'''\\\.''', r'''.''', text) - text = re.sub(r'''\\-''', r'''-''', text) - text = re.sub(r'''\\`''', r'''`''', text) + text = text.replace(r'\\', '\') + text = text.replace(r'\"', '"') + text = text.replace(r"\'", ''') + text = text.replace(r'\.', '.') + text = text.replace(r'\-', '-') + text = text.replace(r'\`', '`') return text diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 5964d0eeae..a84c8f7e79 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -645,7 +645,7 @@ class BasicNewsRecipe(Recipe): `soup`: A `BeautifulSoup `__ instance containing the downloaded :term:`HTML`. ''' - return None + return def abort_article(self, msg=None): ''' Call this method inside any of the preprocess methods to abort the