diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 9c503e932..ef3fd9910 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -156,8 +156,8 @@ class Application(QApplication): The argv list to be passed to Qt. """ argv = [sys.argv[0]] - qt_args = ['style', 'stylesheet', 'widget-count', 'reverse', - 'qmljsdebugger'] + qt_args = ('style', 'stylesheet', 'widget-count', 'reverse', + 'qmljsdebugger') for argname in qt_args: val = getattr(namespace, 'qt_' + argname, None) if val is None: @@ -375,9 +375,9 @@ class Application(QApplication): # config self.config.style_changed.connect(style.invalidate_caches) - for obj in [tabs, completion, self.mainwindow, self.cmd_history, + for obj in (tabs, completion, self.mainwindow, self.cmd_history, websettings, kp['normal'], self.modeman, status, - status.txt]: + status.txt): self.config.changed.connect(obj.on_config_changed) # statusbar diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 6a84761f2..85497aeb8 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -268,14 +268,14 @@ class HintManager(QObject): pos = webelem.rect_on_view(elem).center() logger.debug("Clicking on '{}' at {}/{}".format(elem.toPlainText(), pos.x(), pos.y())) - events = [ + events = ( QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton, Qt.NoModifier), QMouseEvent(QEvent.MouseButtonPress, pos, Qt.LeftButton, Qt.NoButton, Qt.NoModifier), QMouseEvent(QEvent.MouseButtonRelease, pos, Qt.LeftButton, Qt.NoButton, Qt.NoModifier), - ] + ) for evt in events: self.mouse_event.emit(evt) @@ -330,7 +330,7 @@ class HintManager(QObject): # First check for elems = frame.findAllElements( webelem.SELECTORS[webelem.Group.prevnext_rel]) - rel_values = ['prev', 'previous'] if prev else ['next'] + rel_values = ('prev', 'previous') if prev else ('next') for e in elems: if e.attribute('rel') in rel_values: return e diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 3d63977ed..a6b63b8f9 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -347,7 +347,7 @@ class ConfigManager(QObject): except KeyError: raise NoOptionError(optname, sectname) else: - if sectname in ['colors', 'fonts']: + if sectname in ('colors', 'fonts'): self.style_changed.emit(sectname, optname) self.changed.emit(sectname, optname) diff --git a/qutebrowser/config/conftypes.py b/qutebrowser/config/conftypes.py index 16ba409cf..2095db8ac 100644 --- a/qutebrowser/config/conftypes.py +++ b/qutebrowser/config/conftypes.py @@ -459,7 +459,7 @@ class Color(CssColor): typestr = 'color' - _GRADIENTS = ['qlineargradient', 'qradialgradient', 'qconicalgradient'] + _GRADIENTS = ('qlineargradient', 'qradialgradient', 'qconicalgradient') def validate(self, value): if any([value.startswith(start) for start in Color._GRADIENTS]): @@ -775,13 +775,13 @@ class AutoSearch(BaseType): ('false', "Never search automatically.")) def validate(self, value): - if value.lower() in ['naive', 'dns']: + if value.lower() in ('naive', 'dns'): pass else: Bool.validate(self, value) def transform(self, value): - if value.lower() in ['naive', 'dns']: + if value.lower() in ('naive', 'dns'): return value.lower() elif super().transform(value): # boolean true is an alias for naive matching diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py index 21a391f0a..b53c8d693 100644 --- a/qutebrowser/keyinput/basekeyparser.py +++ b/qutebrowser/keyinput/basekeyparser.py @@ -92,15 +92,15 @@ class BaseKeyParser(QObject): Return: The normalized keystring. """ - replacements = [ + replacements = ( ('Control', 'Ctrl'), ('Windows', 'Meta'), ('Mod1', 'Alt'), ('Mod4', 'Meta'), - ] + ) for (orig, repl) in replacements: keystr = keystr.replace(orig, repl) - for mod in ['Ctrl', 'Meta', 'Alt', 'Shift']: + for mod in ('Ctrl', 'Meta', 'Alt', 'Shift'): keystr = keystr.replace(mod + '-', mod + '+') keystr = QKeySequence(keystr).toString() return keystr @@ -122,7 +122,7 @@ class BaseKeyParser(QObject): Qt.MetaModifier: 'Meta', Qt.ShiftModifier: 'Shift' } - if e.key() in [Qt.Key_Control, Qt.Key_Alt, Qt.Key_Shift, Qt.Key_Meta]: + if e.key() in (Qt.Key_Control, Qt.Key_Alt, Qt.Key_Shift, Qt.Key_Meta): # Only modifier pressed return False mod = e.modifiers() diff --git a/qutebrowser/test/keyinput/test_basekeyparser.py b/qutebrowser/test/keyinput/test_basekeyparser.py index 693783c31..a8ce9b33e 100644 --- a/qutebrowser/test/keyinput/test_basekeyparser.py +++ b/qutebrowser/test/keyinput/test_basekeyparser.py @@ -1,4 +1,4 @@ -# Copyright 2014 Florian Bruhin (The Compiler) +# Copyright 2014 Florian Bruhin (The Compiler) : # # This file is part of qutebrowser. # @@ -63,7 +63,7 @@ class ConfigStub: Return: The section as dict. """ - if name not in ['test', 'test2']: + if name not in ('test', 'test2'): raise ValueError("section called with section '{}'!".format(name)) return self.DATA[name] @@ -91,14 +91,14 @@ class NormalizeTests(TestCase): def test_normalize(self): """Test normalize with some strings.""" - STRINGS = [ + STRINGS = ( ('Control+x', 'Ctrl+X'), ('Windows+x', 'Meta+X'), ('Mod1+x', 'Alt+X'), ('Mod4+x', 'Meta+X'), ('Control--', 'Ctrl+-'), ('Windows++', 'Meta++'), - ] + ) for orig, repl in STRINGS: self.assertEqual(self.kp._normalize_keystr(orig), repl, orig) diff --git a/qutebrowser/test/utils/test_misc.py b/qutebrowser/test/utils/test_misc.py index b28d1fb29..a524ceabb 100644 --- a/qutebrowser/test/utils/test_misc.py +++ b/qutebrowser/test/utils/test_misc.py @@ -204,19 +204,19 @@ class ShellEscapeTests(TestCase): platform: The saved sys.platform value. """ - TEXTS_LINUX = [ + TEXTS_LINUX = ( ('', "''"), ('foo%bar+baz', 'foo%bar+baz'), ('foo$bar', "'foo$bar'"), ("$'b", """'$'"'"'b'"""), - ] + ) - TEXTS_WINDOWS = [ + TEXTS_WINDOWS = ( ('', '""'), ('foo*bar?baz', 'foo*bar?baz'), ("a&b|c^df%", "a^&b^|c^^d^f^%"), ('foo"bar', 'foo"""bar'), - ] + ) def setUp(self): self.platform = sys.platform diff --git a/qutebrowser/test/utils/test_url.py b/qutebrowser/test/utils/test_url.py index 82bf8cd0d..4cf2f6c2d 100644 --- a/qutebrowser/test/utils/test_url.py +++ b/qutebrowser/test/utils/test_url.py @@ -106,16 +106,16 @@ class SpecialURLTests(TestCase): NORMAL_URLS: URLs which are not special. """ - SPECIAL_URLS = [ + SPECIAL_URLS = ( 'file:///tmp/foo', 'about:blank', 'qute:version' - ] + ) - NORMAL_URLS = [ + NORMAL_URLS = ( 'http://www.qutebrowser.org/', 'www.qutebrowser.org' - ] + ) def test_special_urls(self): """Test special URLs.""" @@ -176,18 +176,18 @@ class IsUrlNaiveTests(TestCase): NOT_URLS: A list of strings which aren't URLs. """ - URLS = [ + URLS = ( 'http://foobar', 'localhost:8080', 'qutebrowser.org', - ] + ) - NOT_URLS = [ + NOT_URLS = ( 'foo bar', 'localhost test', 'another . test', 'foo', - ] + ) def test_urls(self): """Test things which are URLs.""" diff --git a/qutebrowser/test/utils/test_webelem.py b/qutebrowser/test/utils/test_webelem.py index 24501f571..d4df78114 100644 --- a/qutebrowser/test/utils/test_webelem.py +++ b/qutebrowser/test/utils/test_webelem.py @@ -290,12 +290,12 @@ class JavascriptEscapeTests(TestCase): STRINGS: A list of (input, output) tuples. """ - STRINGS = [ + STRINGS = ( ('foo\\bar', r'foo\\bar'), ('foo\nbar', r'foo\nbar'), ("foo'bar", r"foo\'bar"), ('foo"bar', r'foo\"bar'), - ] + ) def test_fake_escape(self): for before, after in self.STRINGS: diff --git a/qutebrowser/utils/earlyinit.py b/qutebrowser/utils/earlyinit.py index 13f9d95f5..c850b068b 100644 --- a/qutebrowser/utils/earlyinit.py +++ b/qutebrowser/utils/earlyinit.py @@ -88,7 +88,7 @@ def fix_harfbuzz(args): else: logger.debug("Using old harfbuzz engine (auto)") os.environ['QT_HARFBUZZ'] = 'old' - elif args.harfbuzz in ['old', 'new']: + elif args.harfbuzz in ('old', 'new'): # forced harfbuzz variant # FIXME looking at the Qt code, 'new' isn't a valid value, but leaving # it empty and using new yields different behaviour... diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index e549174ed..2466be5ca 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -177,9 +177,9 @@ def qt_message_handler(msg_type, context, msg): # Change levels of some well-known messages to debug so they don't get # shown to the user. # suppressed_msgs is a list of regexes matching the message texts to hide. - suppressed_msgs = ["libpng warning: iCCP: Not recognizing known sRGB " + suppressed_msgs = ("libpng warning: iCCP: Not recognizing known sRGB " "profile that has been edited", - "OpenType support missing for script [0-9]*"] + "OpenType support missing for script [0-9]*") if any(re.match(pattern, msg.strip()) for pattern in suppressed_msgs): level = logging.DEBUG else: diff --git a/qutebrowser/utils/style.py b/qutebrowser/utils/style.py index 431e19ae5..f4f2bfbb6 100644 --- a/qutebrowser/utils/style.py +++ b/qutebrowser/utils/style.py @@ -50,12 +50,12 @@ class Style(QCommonStyle): style: The base/"parent" style. """ self._style = style - for method in ['drawComplexControl', 'drawControl', 'drawItemPixmap', + for method in ('drawComplexControl', 'drawControl', 'drawItemPixmap', 'drawItemText', 'generatedIconPixmap', 'hitTestComplexControl', 'itemPixmapRect', 'itemTextRect', 'pixelMetric', 'polish', 'styleHint', 'subControlRect', 'subElementRect', 'unpolish', - 'sizeFromContents']: + 'sizeFromContents'): target = getattr(self._style, method) setattr(self, method, functools.partial(target)) super().__init__() diff --git a/qutebrowser/utils/url.py b/qutebrowser/utils/url.py index 362c4179b..1b2a553d3 100644 --- a/qutebrowser/utils/url.py +++ b/qutebrowser/utils/url.py @@ -73,7 +73,7 @@ def _is_url_naive(url): Return: True if the URL really is a URL, False otherwise. """ - protocols = ['http', 'https'] + protocols = ('http', 'https') u = qurl(url) urlstr = urlstring(url) if isinstance(url, QUrl): @@ -159,7 +159,7 @@ def fuzzy_url(url): def is_special_url(url): """Return True if url is an about:... or other special URL.""" - special_schemes = ['about', 'qute', 'file'] + special_schemes = ('about', 'qute', 'file') return qurl(url).scheme() in special_schemes diff --git a/qutebrowser/utils/webelem.py b/qutebrowser/utils/webelem.py index 487340fd2..eba800329 100644 --- a/qutebrowser/utils/webelem.py +++ b/qutebrowser/utils/webelem.py @@ -128,12 +128,12 @@ def javascript_escape(text): """ # This is a list of tuples because order matters, and using OrderedDict # makes no sense because we don't actually need dict-like properties. - replacements = [ + replacements = ( ('\\', r'\\'), # First escape all literal \ signs as \\. ("'", r"\'"), # Then escape ' and " as \' and \". ('"', r'\"'), # (note it won't hurt when we escape the wrong one). ('\n', r'\n'), # We also need to escape newlines for some reason. - ] + ) for orig, repl in replacements: text = text.replace(orig, repl) return text diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index 24788da4f..08acc6200 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -83,7 +83,7 @@ class CompletionView(QTreeView): {color[completion.item.selected.fg]} }} """ - COLUMN_WIDTHS = [20, 70, 10] + COLUMN_WIDTHS = (20, 70, 10) # FIXME style scrollbar diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index ce650b9ce..e6b52f38c 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -89,7 +89,7 @@ class MainWindow(QWidget): @pyqtSlot(str, str) def on_config_changed(self, section, option): """Resize completion if config changed.""" - if section == 'completion' and option in ['height', 'shrink']: + if section == 'completion' and option in ('height', 'shrink'): self.resize_completion() @pyqtSlot() diff --git a/qutebrowser/widgets/statusbar/prompt.py b/qutebrowser/widgets/statusbar/prompt.py index 69c8a5126..3da89e94e 100644 --- a/qutebrowser/widgets/statusbar/prompt.py +++ b/qutebrowser/widgets/statusbar/prompt.py @@ -71,7 +71,7 @@ class Prompt(QWidget): cancelled: Emitted when the mode was forcibly left by the user without answering the question. """ - if mode in ['prompt', 'yesno']: + if mode in ('prompt', 'yesno'): self._txt.setText('') self._input.clear() self._input.setEchoMode(QLineEdit.Normal) diff --git a/qutebrowser/widgets/statusbar/url.py b/qutebrowser/widgets/statusbar/url.py index 62235afde..9c5610ca8 100644 --- a/qutebrowser/widgets/statusbar/url.py +++ b/qutebrowser/widgets/statusbar/url.py @@ -147,7 +147,7 @@ class Url(TextBase): Args: status: The LoadStatus as string. """ - if status in ['success', 'error', 'warn']: + if status in ('success', 'error', 'warn'): self.normal_url_type = status else: self.normal_url_type = 'normal' @@ -186,7 +186,7 @@ class Url(TextBase): self.hover_url = None self.normal_url = tab.url_text status = LoadStatus[tab.load_status] - if status in ['success', 'error', 'warn']: + if status in ('success', 'error', 'warn'): self.normal_url_type = status else: self.normal_url_type = 'normal' diff --git a/qutebrowser/widgets/webview.py b/qutebrowser/widgets/webview.py index fb39bddfc..4045d97c6 100644 --- a/qutebrowser/widgets/webview.py +++ b/qutebrowser/widgets/webview.py @@ -191,7 +191,7 @@ class WebView(QWebView): return False elem = hitresult.element() tag = elem.tagName().lower() - if tag in ['embed', 'applet', 'select']: + if tag in ('embed', 'applet', 'select'): # Flash/Java/... return True if tag == 'object': @@ -401,7 +401,7 @@ class WebView(QWebView): @pyqtSlot(str, str) def on_config_changed(self, section, option): """Update tab config when config was changed.""" - if section == 'ui' and option in ['zoom-levels', 'default-zoom']: + if section == 'ui' and option in ('zoom-levels', 'default-zoom'): self._init_neighborlist() @pyqtSlot('QMouseEvent') @@ -413,7 +413,7 @@ class WebView(QWebView): @pyqtSlot() def on_load_started(self): """Leave insert/hint mode and set vars when a new page is loading.""" - for mode in ['insert', 'hint']: + for mode in ('insert', 'hint'): modeman.maybe_leave(mode, 'load started') self.progress = 0 self._has_ssl_errors = False @@ -525,7 +525,7 @@ class WebView(QWebView): Return: The superclass return value. """ - if e.button() in [Qt.XButton1, Qt.XButton2]: + if e.button() in (Qt.XButton1, Qt.XButton2): self._mousepress_backforward(e) return super().mousePressEvent(e) self._mousepress_insertmode(e) diff --git a/scripts/cleanup.py b/scripts/cleanup.py index 2a46805ba..e5e7f53d2 100644 --- a/scripts/cleanup.py +++ b/scripts/cleanup.py @@ -26,10 +26,10 @@ import shutil from fnmatch import fnmatch -recursive_lint = ['__pycache__', '*.pyc'] -lint = ['build', 'dist', 'pkg/pkg', 'pkg/qutebrowser-*.pkg.tar.xz', 'pkg/src', +recursive_lint = ('__pycache__', '*.pyc') +lint = ('build', 'dist', 'pkg/pkg', 'pkg/qutebrowser-*.pkg.tar.xz', 'pkg/src', 'pkg/qutebrowser', 'qutebrowser.egg-info', 'setuptools-*.egg', - 'setuptools-*.zip'] + 'setuptools-*.zip') def remove(path): diff --git a/scripts/run_checks.py b/scripts/run_checks.py index 8915fffd6..ae7d9ccf4 100755 --- a/scripts/run_checks.py +++ b/scripts/run_checks.py @@ -262,21 +262,21 @@ for trg in options['targets']: print("==================== {} ====================".format(trg)) if do_check_257: check_pep257(trg, _get_args('pep257')) - for chk in ['pylint', 'flake8']: + for chk in ('pylint', 'flake8'): # FIXME what the hell is the flake8 exit status? run(chk, trg, _get_args(chk)) check_line(trg, ) if '--setup' in argv: print("==================== Setup checks ====================") - for chk in ['pyroma', 'check-manifest']: + for chk in ('pyroma', 'check-manifest'): run(chk, args=_get_args(chk)) print("Exit status values:") for (k, v) in status.items(): print(' {} - {}'.format(k, v)) -if all(val in [True, 0] for val in status): +if all(val in (True, 0) for val in status): sys.exit(0) else: sys.exit(1)