mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
add scoped noqa (auto-fix)
ruff --add-noqa
This commit is contained in:
parent
05c9729698
commit
d08949b012
@ -47,11 +47,11 @@ templates_path = ['templates']
|
||||
source_suffix = {'.rst': 'restructuredtext'}
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index' if tags.has('online') else 'simple_index'
|
||||
master_doc = 'index' if tags.has('online') else 'simple_index' # noqa: F821
|
||||
# kill the warning about index/simple_index not being in a toctree
|
||||
exclude_patterns = ['simple_index.rst'] if master_doc == 'index' else ['index.rst']
|
||||
exclude_patterns.append('cli-options-header.rst')
|
||||
if tags.has('gettext'):
|
||||
if tags.has('gettext'): # noqa: F821
|
||||
# Do not exclude anything as the strings must be translated. This will
|
||||
# generate a warning about the documents not being in a toctree, just ignore
|
||||
# it.
|
||||
|
@ -32,7 +32,7 @@ class DemoTool(Tool):
|
||||
def create_action(self, for_toolbar=True):
|
||||
# Create an action, this will be added to the plugins toolbar and
|
||||
# the plugins menu
|
||||
ac = QAction(get_icons('images/icon.png'), 'Magnify fonts', self.gui)
|
||||
ac = QAction(get_icons('images/icon.png'), 'Magnify fonts', self.gui) # noqa: F821
|
||||
if not for_toolbar:
|
||||
# Register a keyboard shortcut for this toolbar action. We only
|
||||
# register it for the action created for the menu, not the toolbar,
|
||||
|
@ -61,7 +61,7 @@ class MediaDaumRecipe(BasicNewsRecipe):
|
||||
lambda match: '<em>'),
|
||||
(re.compile(r'<i>(<br[^>]*>[ \t\r\n]*)*', re.DOTALL | re.IGNORECASE),
|
||||
lambda match: '<i>'),
|
||||
(re.compile(u'(<br[^>]*>[ \t\r\n]*)*(\u25B6|\u25CF|\u261E|\u24D2|\(c\))*\[[^\]]*(\u24D2|\(c\)|\uAE30\uC0AC|\uC778\uAE30[^\]]*\uB274\uC2A4)[^\]]*\].*</div>', re.DOTALL | re.IGNORECASE), # noqa: E501
|
||||
(re.compile(u'(<br[^>]*>[ \t\r\n]*)*(\u25B6|\u25CF|\u261E|\u24D2|\(c\))*\[[^\]]*(\u24D2|\(c\)|\uAE30\uC0AC|\uC778\uAE30[^\]]*\uB274\uC2A4)[^\]]*\].*</div>', re.DOTALL | re.IGNORECASE), # noqa: E501, W605
|
||||
lambda match: '</div>'),
|
||||
]
|
||||
|
||||
|
@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
from pprint import pprint
|
||||
from pprint import pprint # noqa: F401
|
||||
|
||||
from calibre import strftime
|
||||
from calibre.ebooks.BeautifulSoup import Tag
|
||||
|
@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
from pprint import pprint
|
||||
from pprint import pprint # noqa: F401
|
||||
|
||||
from calibre import strftime
|
||||
from calibre.ebooks.BeautifulSoup import Tag
|
||||
|
@ -14,7 +14,7 @@ def find_tests():
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
import init_calibre
|
||||
import init_calibre # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
run_tests(find_tests)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
import bs4
|
||||
from bs4 import CData, Comment, Declaration, NavigableString, ProcessingInstruction, SoupStrainer, Tag, __version__
|
||||
from bs4 import CData, Comment, Declaration, NavigableString, ProcessingInstruction, SoupStrainer, Tag, __version__ # noqa: F401
|
||||
|
||||
|
||||
def parse_html(markup):
|
||||
|
@ -151,7 +151,7 @@ class PDFOutput(OutputFormatPlugin):
|
||||
# Ensure Qt is setup to be used with WebEngine
|
||||
# specialize_options is called early enough in the pipeline
|
||||
# that hopefully no Qt application has been constructed as yet
|
||||
from qt.webengine import QWebEnginePage
|
||||
from qt.webengine import QWebEnginePage # noqa: I001, F401
|
||||
from calibre.gui2 import must_use_qt
|
||||
from calibre.utils.webengine import setup_fake_protocol, setup_default_profile
|
||||
setup_fake_protocol()
|
||||
|
@ -1073,7 +1073,7 @@ OptionRecommendation(name='search_replace',
|
||||
self.flush()
|
||||
if self.opts.embed_all_fonts or self.opts.embed_font_family:
|
||||
# Start the threaded font scanner now, for performance
|
||||
from calibre.utils.fonts.scanner import font_scanner
|
||||
from calibre.utils.fonts.scanner import font_scanner # noqa: F401
|
||||
import logging
|
||||
|
||||
import css_parser
|
||||
|
@ -58,7 +58,7 @@ from calibre.ebooks.metadata.opf3 import (
|
||||
)
|
||||
|
||||
# This import is needed to prevent a test from running slowly
|
||||
from calibre.ebooks.oeb.polish.pretty import pretty_opf, pretty_xml_tree
|
||||
from calibre.ebooks.oeb.polish.pretty import pretty_opf, pretty_xml_tree # noqa: F401
|
||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||
|
||||
read_user_categories, set_user_categories, read_link_maps, set_link_maps
|
||||
|
@ -13,7 +13,7 @@ def find_tests():
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
import init_calibre
|
||||
import init_calibre # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
run_tests(find_tests)
|
||||
|
@ -302,7 +302,7 @@ class SubsetFonts:
|
||||
|
||||
def find_chars(self, elem, style):
|
||||
ans = set()
|
||||
transform = lambda x: x
|
||||
transform = lambda x: x # noqa: E731
|
||||
tt = style.get('text-transform')
|
||||
if tt:
|
||||
if tt in ('uppercase', 'capitalize'):
|
||||
|
@ -86,7 +86,7 @@ class MarkdownMLizer(OEB2HTML):
|
||||
# Condense redundant spaces created by replacing newlines with spaces.
|
||||
text = re.sub(r'[ ]{2,}', ' ', text)
|
||||
text = re.sub(r'\t+', '', text)
|
||||
if self.remove_space_after_newline == True:
|
||||
if self.remove_space_after_newline == True: # noqa: E712
|
||||
text = re.sub(r'^ +', '', text)
|
||||
self.remove_space_after_newline = False
|
||||
return text
|
||||
@ -148,13 +148,13 @@ class MarkdownMLizer(OEB2HTML):
|
||||
|
||||
if style['font-style'] == 'italic' or tag in ('i', 'em'):
|
||||
if tag not in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'cite'):
|
||||
if self.style_italic == False:
|
||||
if self.style_italic == False: # noqa: E712
|
||||
text.append('*')
|
||||
tags.append('*')
|
||||
self.style_italic = True
|
||||
if style['font-weight'] in ('bold', 'bolder') or tag in ('b', 'strong'):
|
||||
if tag not in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'th'):
|
||||
if self.style_bold == False:
|
||||
if self.style_bold == False: # noqa: E712
|
||||
text.append('**')
|
||||
tags.append('**')
|
||||
self.style_bold = True
|
||||
|
@ -138,7 +138,7 @@ class TextileMLizer(OEB2HTML):
|
||||
# Condense redundant spaces created by replacing newlines with spaces.
|
||||
text = re.sub(r'[ ]{2,}', ' ', text)
|
||||
text = re.sub(r'\t+', '', text)
|
||||
if self.remove_space_after_newline == True:
|
||||
if self.remove_space_after_newline == True: # noqa: E712
|
||||
text = re.sub(r'^ +', '', text)
|
||||
self.remove_space_after_newline = False
|
||||
return text
|
||||
@ -268,7 +268,7 @@ class TextileMLizer(OEB2HTML):
|
||||
|
||||
if style['font-style'] == 'italic' or tag in ('i', 'em'):
|
||||
if tag not in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'cite'):
|
||||
if self.style_italic == False:
|
||||
if self.style_italic == False: # noqa: E712
|
||||
if self.in_a_link:
|
||||
text.append('_')
|
||||
tags.append('_')
|
||||
@ -279,7 +279,7 @@ class TextileMLizer(OEB2HTML):
|
||||
self.style_italic = True
|
||||
if style['font-weight'] in ('bold', 'bolder') or tag in ('b', 'strong'):
|
||||
if tag not in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'th'):
|
||||
if self.style_bold == False:
|
||||
if self.style_bold == False: # noqa: E712
|
||||
if self.in_a_link:
|
||||
text.append('*')
|
||||
tags.append('*')
|
||||
@ -290,13 +290,13 @@ class TextileMLizer(OEB2HTML):
|
||||
self.style_bold = True
|
||||
if style['text-decoration'] == 'underline' or tag in ('u', 'ins'):
|
||||
if tag != 'a':
|
||||
if self.style_under == False:
|
||||
if self.style_under == False: # noqa: E712
|
||||
text.append('[+')
|
||||
tags.append('+]')
|
||||
self.style_embed.append('+')
|
||||
self.style_under = True
|
||||
if style['text-decoration'] == 'line-through' or tag in ('strike', 'del', 's'):
|
||||
if self.style_strike == False:
|
||||
if self.style_strike == False: # noqa: E712
|
||||
text.append('[-')
|
||||
tags.append('-]')
|
||||
self.style_embed.append('-')
|
||||
@ -423,12 +423,12 @@ class TextileMLizer(OEB2HTML):
|
||||
tags.append('')
|
||||
elif tag == 'span':
|
||||
if style['font-variant'] == 'small-caps':
|
||||
if self.style_smallcap == False:
|
||||
if self.style_smallcap == False: # noqa: E712
|
||||
text.append('&')
|
||||
tags.append('&')
|
||||
self.style_smallcap = True
|
||||
else:
|
||||
if self.in_a_link == False:
|
||||
if self.in_a_link == False: # noqa: E712
|
||||
txt = '%'
|
||||
if self.opts.keep_links:
|
||||
txt += self.check_id_tag(attribs)
|
||||
|
@ -266,14 +266,14 @@ class SearchFilter(SearchQueryParser):
|
||||
accessor = q[locvalue]
|
||||
if query == 'true':
|
||||
if locvalue in ('affiliate', 'drm', 'enabled'):
|
||||
if accessor(sr) == True:
|
||||
if accessor(sr) == True: # noqa: E712
|
||||
matches.add(sr)
|
||||
elif accessor(sr) is not None:
|
||||
matches.add(sr)
|
||||
continue
|
||||
if query == 'false':
|
||||
if locvalue in ('affiliate', 'drm', 'enabled'):
|
||||
if accessor(sr) == False:
|
||||
if accessor(sr) == False: # noqa: E712
|
||||
matches.add(sr)
|
||||
elif accessor(sr) is None:
|
||||
matches.add(sr)
|
||||
|
@ -4,4 +4,4 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from calibre.gui2.tweak_book.editor.syntax.html import XMLHighlighter as Highlighter
|
||||
from calibre.gui2.tweak_book.editor.syntax.html import XMLHighlighter as Highlighter # noqa: F401
|
||||
|
@ -650,7 +650,7 @@ def launch_editor(path_to_edit, path_is_raw=False, syntax='html', callback=None)
|
||||
opts = option_parser().parse_args([])
|
||||
app = Application([])
|
||||
# Create the actions that are placed into the editors toolbars
|
||||
main = Main(opts)
|
||||
main = Main(opts) # noqa: F841
|
||||
if path_is_raw:
|
||||
raw = path_to_edit
|
||||
else:
|
||||
|
@ -13,7 +13,7 @@ def find_tests():
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
import init_calibre
|
||||
import init_calibre # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
run_tests(find_tests)
|
||||
|
@ -106,8 +106,8 @@ class BuildTest(unittest.TestCase):
|
||||
self.assertEqual(data, decompress(cdata))
|
||||
|
||||
def test_html5lib(self):
|
||||
import html5lib.html5parser
|
||||
from html5lib import parse
|
||||
import html5lib.html5parser # noqa: F401
|
||||
from html5lib import parse # noqa: F401
|
||||
|
||||
def test_html5_parser(self):
|
||||
from html5_parser import parse
|
||||
|
@ -172,14 +172,14 @@ def simple_repl(user_ns={}):
|
||||
setup_pyreadline()
|
||||
else:
|
||||
try:
|
||||
import rlcompleter
|
||||
import rlcompleter # noqa: I001, F401
|
||||
import readline
|
||||
readline.parse_and_bind("tab: complete")
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
user_ns = user_ns or {}
|
||||
import sys, re
|
||||
import sys, re # noqa: I001, E401, F401
|
||||
for x in ('os', 'sys', 're'):
|
||||
user_ns[x] = user_ns.get(x, globals().get(x, locals().get(x)))
|
||||
user_ns['exit'] = Exit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user