summaryrefslogtreecommitdiff
path: root/qutebrowser/components
diff options
context:
space:
mode:
authorÁrni Dagur <arnidg@protonmail.ch>2020-11-03 00:19:04 +0000
committerÁrni Dagur <arni@dagur.eu>2020-12-19 20:29:51 +0000
commit71451483f4f380c2f70f6e5b28025af79b1168e5 (patch)
tree428b7f5e216ccbe2dcf8c92fad5d5cf8fcc26bd5 /qutebrowser/components
parent0a9da570085b198fbcba6238a54c49757a8a962e (diff)
downloadqutebrowser-71451483f4f380c2f70f6e5b28025af79b1168e5.tar.gz
qutebrowser-71451483f4f380c2f70f6e5b28025af79b1168e5.zip
Fix lint complaints
Diffstat (limited to 'qutebrowser/components')
-rw-r--r--qutebrowser/components/braveadblock.py27
-rw-r--r--qutebrowser/components/utils/blockutils.py12
2 files changed, 18 insertions, 21 deletions
diff --git a/qutebrowser/components/braveadblock.py b/qutebrowser/components/braveadblock.py
index 04a492417..36b7f481e 100644
--- a/qutebrowser/components/braveadblock.py
+++ b/qutebrowser/components/braveadblock.py
@@ -21,9 +21,9 @@
import io
import logging
-import typing
import pathlib
import functools
+from typing import Optional, IO
from PyQt5.QtCore import QUrl
@@ -39,20 +39,21 @@ from qutebrowser.api.interceptor import ResourceType
from qutebrowser.components.utils import blockutils
from qutebrowser.utils import version
-_outdated_version: typing.Optional[str] = None
try:
import adblock
-
- adblock_info = version.MODULE_INFO["adblock"]
- if adblock_info.is_outdated():
- adblock = None # type: ignore[assignment]
- _outdated_version = adblock_info.get_version()
except ImportError:
adblock = None # type: ignore[assignment]
+_outdated_version: Optional[str] = None
+if adblock is not None:
+ _adblock_info = version.MODULE_INFO["adblock"]
+ if _adblock_info.is_outdated():
+ adblock = None # type: ignore[assignment]
+ _outdated_version = _adblock_info.get_version()
+
logger = logging.getLogger("network")
-ad_blocker: typing.Optional["BraveAdBlocker"] = None
+ad_blocker: Optional["BraveAdBlocker"] = None
def _should_be_used() -> bool:
@@ -77,7 +78,7 @@ def _possibly_show_missing_dependency_warning() -> None:
message.warning(
f"Installed version {_outdated_version} of the"
" 'adblock' dependency is too old. Minimum supported is"
- f" {adblock_info.min_version}."
+ f" {_adblock_info.min_version}."
)
else:
message.warning(
@@ -112,7 +113,7 @@ _RESOURCE_TYPE_STRINGS = {
}
-def resource_type_to_string(resource_type: typing.Optional[ResourceType]) -> str:
+def resource_type_to_string(resource_type: Optional[ResourceType]) -> str:
return _RESOURCE_TYPE_STRINGS.get(resource_type, "other")
@@ -136,8 +137,8 @@ class BraveAdBlocker:
def _is_blocked(
self,
request_url: QUrl,
- first_party_url: typing.Optional[QUrl] = None,
- resource_type: typing.Optional[interceptor.ResourceType] = None,
+ first_party_url: Optional[QUrl] = None,
+ resource_type: Optional[interceptor.ResourceType] = None,
) -> bool:
"""Check whether the given request is blocked."""
if not self.enabled:
@@ -248,7 +249,7 @@ class BraveAdBlocker:
logger.exception("Failed to remove adblock cache file: %s", e)
def _on_download_finished(
- self, fileobj: typing.IO[bytes], filter_set: "adblock.FilterSet"
+ self, fileobj: IO[bytes], filter_set: "adblock.FilterSet"
) -> None:
"""When a blocklist download finishes, add it to the given filter set.
diff --git a/qutebrowser/components/utils/blockutils.py b/qutebrowser/components/utils/blockutils.py
index aa6475dc6..502038f48 100644
--- a/qutebrowser/components/utils/blockutils.py
+++ b/qutebrowser/components/utils/blockutils.py
@@ -20,9 +20,9 @@
"""Code that is shared between the host blocker and Brave ad blocker."""
-import typing
import os
import functools
+from typing import IO, List, Optional
from PyQt5.QtCore import QUrl, QObject, pyqtSignal
@@ -33,7 +33,7 @@ class FakeDownload(downloads.TempDownload):
"""A download stub to use on_download_finished with local files."""
- def __init__(self, fileobj: typing.IO[bytes]) -> None:
+ def __init__(self, fileobj: IO[bytes]) -> None:
# pylint: disable=super-init-not-called
self.fileobj = fileobj
self.successful = True
@@ -63,15 +63,11 @@ class BlocklistDownloads(QObject):
single_download_finished = pyqtSignal(object) # arg: the file object
all_downloads_finished = pyqtSignal(int) # arg: download count
- def __init__(
- self,
- urls: typing.List[QUrl],
- parent: typing.Optional[QObject] = None,
- ) -> None:
+ def __init__(self, urls: List[QUrl], parent: Optional[QObject] = None) -> None:
super().__init__(parent)
self._urls = urls
- self._in_progress: typing.List[downloads.TempDownload] = []
+ self._in_progress: List[downloads.TempDownload] = []
self._done_count = 0
self._finished_registering_downloads = False
self._started = False