This commit is contained in:
Florian Bruhin 2018-02-19 04:30:24 +01:00
parent 7c1fb1d215
commit 14a69d9047
9 changed files with 18 additions and 17 deletions

View File

@ -30,8 +30,8 @@ from PyQt5.QtWidgets import QWidget, QApplication
from qutebrowser.keyinput import modeman
from qutebrowser.config import config
from qutebrowser.utils import (utils, objreg, usertypes, log, qtutils, urlutils,
message)
from qutebrowser.utils import (utils, objreg, usertypes, log, qtutils,
urlutils, message)
from qutebrowser.misc import miscwidgets, objects
from qutebrowser.browser import mouse, hints

View File

@ -29,8 +29,7 @@ from PyQt5.QtWebEngineWidgets import (QWebEngineView, QWebEnginePage,
from qutebrowser.browser import shared
from qutebrowser.browser.webengine import certificateerror, webenginesettings
from qutebrowser.config import config
from qutebrowser.utils import (log, debug, usertypes, jinja, urlutils, message,
objreg, qtutils)
from qutebrowser.utils import log, debug, usertypes, jinja, objreg, qtutils
class WebEngineView(QWebEngineView):

View File

@ -33,8 +33,7 @@ from qutebrowser.config import config
from qutebrowser.browser import pdfjs, shared
from qutebrowser.browser.webkit import http
from qutebrowser.browser.webkit.network import networkmanager
from qutebrowser.utils import (message, usertypes, log, jinja, objreg, debug,
urlutils)
from qutebrowser.utils import message, usertypes, log, jinja, objreg
class BrowserPage(QWebPage):

View File

@ -23,7 +23,6 @@ import copy
import contextlib
import functools
import attr
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject
from qutebrowser.config import configdata, configexc, configutils
@ -234,8 +233,8 @@ class Config(QObject):
"""Main config object.
Class attributes:
MUTABLE_TYPES: Types returned from the config which could potentially be
mutated.
MUTABLE_TYPES: Types returned from the config which could potentially
be mutated.
Attributes:
_values: A dict mapping setting names to configutils.Values objects.
@ -312,8 +311,8 @@ class Config(QObject):
def _maybe_copy(self, value):
"""Copy the value if it could potentially be mutated."""
if isinstance(value, self.MUTABLE_TYPES):
# For mutable objects, create a copy so we don't accidentally mutate
# the config's internal value.
# For mutable objects, create a copy so we don't accidentally
# mutate the config's internal value.
return copy.deepcopy(value)
else:
# Shouldn't be mutable (and thus hashable)
@ -332,8 +331,8 @@ class Config(QObject):
def get_obj_for_pattern(self, name, *, pattern):
"""Get the given setting as object (for YAML/config.py).
This gets the overridden value for a given pattern, or configutils.UNSET
if no such override exists.
This gets the overridden value for a given pattern, or
configutils.UNSET if no such override exists.
"""
value = self._values[name].get_for_pattern(pattern, fallback=False)
return self._maybe_copy(value)

View File

@ -177,7 +177,8 @@ class ConfigCommands:
@cmdutils.register(instance='config-commands', star_args_optional=True)
@cmdutils.argument('option', completion=configmodel.option)
@cmdutils.argument('values', completion=configmodel.value)
def config_cycle(self, option, *values, url=None, temp=False, print_=False):
def config_cycle(self, option, *values, url=None, temp=False,
print_=False):
"""Cycle an option between multiple values.
Args:

View File

@ -102,7 +102,7 @@ class YamlConfig(QObject):
save_manager.add_saveable('yaml-config', self._save, self.changed)
def __iter__(self):
for name, values in sorted(self._values.items()):
for _name, values in sorted(self._values.items()):
yield from values
def _mark_changed(self):
@ -217,7 +217,7 @@ class YamlConfig(QObject):
def _validate(self):
"""Make sure all settings exist."""
unknown = []
for _pattern, name, value in self:
for _pattern, name, _value in self:
# FIXME:conf show pattern
if name not in configdata.DATA:
unknown.append(name)

View File

@ -231,7 +231,7 @@ def update_for_tab(mappings, tab, url):
value = values.get_for_url(url, fallback=False)
# FIXME:conf have a proper API for this.
settings = tab._widget.settings()
settings = tab._widget.settings() # pylint: disable=protected-access
if value is configutils.UNSET:
try:

View File

@ -104,6 +104,7 @@ class UrlPattern:
return hash(self._to_tuple())
def __eq__(self, other):
# pylint: disable=protected-access
return self._to_tuple() == other._to_tuple()
def _fixup_pattern(self, pattern):

View File

@ -400,6 +400,8 @@ class AbstractCertificateErrorWrapper:
@attr.s
class NavigationRequest:
"""A request to navigate to the given URL."""
Type = enum.Enum('Type', [
'link_clicked',
'typed', # QtWebEngine only