pylint: Enable else-if-used

This commit is contained in:
Florian Bruhin 2021-12-03 11:58:41 +01:00
parent b84d68e8ee
commit 4435ef9287
12 changed files with 33 additions and 35 deletions

View File

@ -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

View File

@ -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

View File

@ -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,11 +871,10 @@ 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()
except webelem.Error:
pass

View File

@ -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}'"

View File

@ -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))

View File

@ -272,8 +272,7 @@ class Command:
if is_bool:
kwargs['action'] = 'store_true'
else:
if arg_info.metavar is not None:
elif arg_info.metavar is not None:
kwargs['metavar'] = arg_info.metavar
else:
kwargs['metavar'] = argparser.arg_name(param.name)
@ -320,8 +319,7 @@ 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:
elif not arg_info.hide:
self.pos_args.append((param.name, name))
return args

View File

@ -266,8 +266,7 @@ class BraveAdBlocker:
except DeserializationError:
message.error("Reading adblock filter data failed (corrupted data?). "
"Please run :adblock-update.")
else:
if (
elif (
config.val.content.blocking.adblock.lists
and not self._has_basedir
and config.val.content.blocking.enabled

View File

@ -260,8 +260,7 @@ 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:
elif 'stack' not in namespace.debug_flags:
yield '--disable-in-process-stack-traces'
lang_override = _get_lang_override(

View File

@ -698,8 +698,7 @@ class TabbedBrowser(QWidget):
"""
if tab.data.keep_icon:
tab.data.keep_icon = False
else:
if (config.cache['tabs.tabs_are_windows'] and
elif (config.cache['tabs.tabs_are_windows'] and
tab.data.should_show_icon()):
self.widget.window().setWindowIcon(self.default_window_icon)

View File

@ -206,9 +206,8 @@ 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']

View File

@ -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

View File

@ -391,8 +391,7 @@ def get_repr(obj: Any, constructor: bool = False, **attrs: Any) -> str:
parts.append('{}={!r}'.format(name, val))
if constructor:
return '{}({})'.format(cls, ', '.join(parts))
else:
if parts:
elif parts:
return '<{} {}>'.format(cls, ' '.join(parts))
else:
return '<{}>'.format(cls)