summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-12-03 11:58:41 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-12-03 12:04:59 +0100
commit4435ef928796fa744be5452924a103bb2e58ee8e (patch)
tree73f99cf693fa492ce22e228d16fc1a7eff540e81
parentb84d68e8ee22cb1679799c9ca73397e81110ea34 (diff)
downloadqutebrowser-4435ef928796fa744be5452924a103bb2e58ee8e.tar.gz
qutebrowser-4435ef928796fa744be5452924a103bb2e58ee8e.zip
pylint: Enable else-if-usedpylint-2-12
-rw-r--r--.pylintrc1
-rw-r--r--qutebrowser/browser/commands.py1
-rw-r--r--qutebrowser/browser/hints.py8
-rw-r--r--qutebrowser/browser/shared.py1
-rw-r--r--qutebrowser/browser/signalfilter.py1
-rw-r--r--qutebrowser/commands/command.py12
-rw-r--r--qutebrowser/components/braveadblock.py15
-rw-r--r--qutebrowser/config/qtargs.py5
-rw-r--r--qutebrowser/mainwindow/tabbedbrowser.py7
-rw-r--r--qutebrowser/misc/sessions.py9
-rw-r--r--qutebrowser/utils/urlutils.py1
-rw-r--r--qutebrowser/utils/utils.py7
12 files changed, 33 insertions, 35 deletions
diff --git a/.pylintrc b/.pylintrc
index 474e331e7..96ed44ea1 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -12,6 +12,7 @@ load-plugins=qute_pylint.config,
pylint.extensions.comparison_placement,
pylint.extensions.for_any_all,
pylint.extensions.docstyle,
+ pylint.extensions.check_elif,
pylint.extensions.typing,
persistent=n
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index 796bb2eb3..dc9290b0e 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -1034,6 +1034,7 @@ class CommandDispatcher:
if config.val.tabs.wrap:
new_idx %= self._count()
else:
+ # pylint: disable=else-if-used
# absolute moving
if index == "start":
new_idx = 0
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 6ac44adbc..64062bbc6 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -596,6 +596,7 @@ class HintManager(QObject):
"'args' is required with target userscript/spawn/run/"
"fill.")
else:
+ # pylint: disable=else-if-used
if args:
raise cmdutils.CommandError(
"'args' is only allowed with target userscript/spawn.")
@@ -870,12 +871,11 @@ class HintManager(QObject):
label.update_text(matched, rest)
# Show label again if it was hidden before
label.show()
- else:
+ elif (not self._context.rapid or
+ config.val.hints.hide_unmatched_rapid_hints):
# element doesn't match anymore -> hide it, unless in rapid
# mode and hide_unmatched_rapid_hints is false (see #1799)
- if (not self._context.rapid or
- config.val.hints.hide_unmatched_rapid_hints):
- label.hide()
+ label.hide()
except webelem.Error:
pass
self._handle_auto_follow(keystr=keystr)
diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py
index 2fd0d0c65..41c971642 100644
--- a/qutebrowser/browser/shared.py
+++ b/qutebrowser/browser/shared.py
@@ -508,6 +508,7 @@ def _validated_selected_files(
)
continue
else:
+ # pylint: disable=else-if-used
if not os.path.isfile(selected_file):
message.warning(
f"Expected file but got folder, ignoring '{selected_file}'"
diff --git a/qutebrowser/browser/signalfilter.py b/qutebrowser/browser/signalfilter.py
index 0b002e345..88ac4a65d 100644
--- a/qutebrowser/browser/signalfilter.py
+++ b/qutebrowser/browser/signalfilter.py
@@ -88,6 +88,7 @@ class SignalFilter(QObject):
debug.dbg_signal(signal, args), tabidx))
signal.emit(*args)
else:
+ # pylint: disable=else-if-used
if log_signal:
log.signals.debug("ignoring: {} (tab {})".format(
debug.dbg_signal(signal, args), tabidx))
diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py
index 653f551ff..eee5b7cde 100644
--- a/qutebrowser/commands/command.py
+++ b/qutebrowser/commands/command.py
@@ -272,11 +272,10 @@ class Command:
if is_bool:
kwargs['action'] = 'store_true'
+ elif arg_info.metavar is not None:
+ kwargs['metavar'] = arg_info.metavar
else:
- if arg_info.metavar is not None:
- kwargs['metavar'] = arg_info.metavar
- else:
- kwargs['metavar'] = argparser.arg_name(param.name)
+ kwargs['metavar'] = argparser.arg_name(param.name)
if param.kind == inspect.Parameter.VAR_POSITIONAL:
kwargs['nargs'] = '*' if self._star_args_optional else '+'
@@ -320,9 +319,8 @@ class Command:
self.opt_args[param.name] = long_flag, short_flag
if not is_bool:
self.flags_with_args += [short_flag, long_flag]
- else:
- if not arg_info.hide:
- self.pos_args.append((param.name, name))
+ elif not arg_info.hide:
+ self.pos_args.append((param.name, name))
return args
def _get_type(self, param):
diff --git a/qutebrowser/components/braveadblock.py b/qutebrowser/components/braveadblock.py
index 21319cb1b..b1e5b8a29 100644
--- a/qutebrowser/components/braveadblock.py
+++ b/qutebrowser/components/braveadblock.py
@@ -266,14 +266,13 @@ class BraveAdBlocker:
except DeserializationError:
message.error("Reading adblock filter data failed (corrupted data?). "
"Please run :adblock-update.")
- else:
- if (
- config.val.content.blocking.adblock.lists
- and not self._has_basedir
- and config.val.content.blocking.enabled
- and self.enabled
- ):
- message.info("Run :adblock-update to get adblock lists.")
+ elif (
+ config.val.content.blocking.adblock.lists
+ and not self._has_basedir
+ and config.val.content.blocking.enabled
+ and self.enabled
+ ):
+ message.info("Run :adblock-update to get adblock lists.")
def adblock_update(self) -> blockutils.BlocklistDownloads:
"""Update the adblock block lists."""
diff --git a/qutebrowser/config/qtargs.py b/qutebrowser/config/qtargs.py
index c38ef5b01..2f93b7de5 100644
--- a/qutebrowser/config/qtargs.py
+++ b/qutebrowser/config/qtargs.py
@@ -260,9 +260,8 @@ def _qtwebengine_args(
# Only actually available in Qt 5.12.5, but let's save another
# check, as passing the option won't hurt.
yield '--enable-in-process-stack-traces'
- else:
- if 'stack' not in namespace.debug_flags:
- yield '--disable-in-process-stack-traces'
+ elif 'stack' not in namespace.debug_flags:
+ yield '--disable-in-process-stack-traces'
lang_override = _get_lang_override(
webengine_version=versions.webengine,
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
index 8c6ac2424..c3f06e185 100644
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -698,10 +698,9 @@ class TabbedBrowser(QWidget):
"""
if tab.data.keep_icon:
tab.data.keep_icon = False
- else:
- if (config.cache['tabs.tabs_are_windows'] and
- tab.data.should_show_icon()):
- self.widget.window().setWindowIcon(self.default_window_icon)
+ elif (config.cache['tabs.tabs_are_windows'] and
+ tab.data.should_show_icon()):
+ self.widget.window().setWindowIcon(self.default_window_icon)
@pyqtSlot()
def _on_load_status_changed(self, tab):
diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py
index 11af329e0..a28f3a848 100644
--- a/qutebrowser/misc/sessions.py
+++ b/qutebrowser/misc/sessions.py
@@ -206,12 +206,11 @@ class SessionManager(QObject):
if item.title():
data['title'] = item.title()
- else:
+ elif tab.history.current_idx() == idx:
# https://github.com/qutebrowser/qutebrowser/issues/879
- if tab.history.current_idx() == idx:
- data['title'] = tab.title()
- else:
- data['title'] = data['url']
+ data['title'] = tab.title()
+ else:
+ data['title'] = data['url']
if item.originalUrl() != item.url():
encoded = item.originalUrl().toEncoded()
diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py
index 002f10411..68520a706 100644
--- a/qutebrowser/utils/urlutils.py
+++ b/qutebrowser/utils/urlutils.py
@@ -95,6 +95,7 @@ def _parse_search_term(s: str) -> Tuple[Optional[str], Optional[str]]:
engine = None
term = s
else:
+ # pylint: disable=else-if-used
if config.val.url.open_base_url and s in config.val.url.searchengines:
engine = s
term = None
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index f42515c5c..75da5028b 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -391,11 +391,10 @@ def get_repr(obj: Any, constructor: bool = False, **attrs: Any) -> str:
parts.append('{}={!r}'.format(name, val))
if constructor:
return '{}({})'.format(cls, ', '.join(parts))
+ elif parts:
+ return '<{} {}>'.format(cls, ' '.join(parts))
else:
- if parts:
- return '<{} {}>'.format(cls, ' '.join(parts))
- else:
- return '<{}>'.format(cls)
+ return '<{}>'.format(cls)
def qualname(obj: Any) -> str: