From 58d179302edcf9c4be980494494cdde55f6e02f0 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 10 Dec 2018 14:55:28 +0100 Subject: [PATCH] Add api.config.get --- qutebrowser/api/config.py | 12 ++++++++---- qutebrowser/components/adblock.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/qutebrowser/api/config.py b/qutebrowser/api/config.py index ad0338dd2..c2831de40 100644 --- a/qutebrowser/api/config.py +++ b/qutebrowser/api/config.py @@ -21,11 +21,15 @@ import typing -MYPY = False -if MYPY: - # pylint: disable=unused-import,useless-suppression - from qutebrowser.config import config +from PyQt5.QtCore import QUrl + +from qutebrowser.config import config # pylint: disable=unused-import from qutebrowser.config.config import change_filter val = typing.cast('config.ConfigContainer', None) + + +def get(name: str, url: QUrl = None) -> typing.Any: + """Get a value from the config based on a string name.""" + return config.instance.get(name, url) diff --git a/qutebrowser/components/adblock.py b/qutebrowser/components/adblock.py index 77e7a7694..492acb0a8 100644 --- a/qutebrowser/components/adblock.py +++ b/qutebrowser/components/adblock.py @@ -112,8 +112,8 @@ class HostBlocker: """Check if the given URL (as QUrl) is blocked.""" if first_party_url is not None and not first_party_url.isValid(): first_party_url = None - if not config.instance.get('content.host_blocking.enabled', - url=first_party_url): + if not config.get('content.host_blocking.enabled', + url=first_party_url): return False host = url.host()