From b37dbc45723bee27a5ba0d5e7cfea1c64e0cc1f2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 22 Nov 2018 14:19:31 +0100 Subject: [PATCH] mypy: Add missing annotations --- qutebrowser/browser/commands.py | 2 +- qutebrowser/browser/webkit/network/networkmanager.py | 4 +++- qutebrowser/commands/cmdutils.py | 9 +++------ qutebrowser/config/configcache.py | 4 +++- qutebrowser/config/configtypes.py | 5 +++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index ceafbc011..e94e55c3d 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -645,7 +645,7 @@ class CommandDispatcher: inc_or_dec='decrement'), 'increment': functools.partial(navigate.incdec, inc_or_dec='increment'), - } + } # type: typing.Dict[str, typing.Callable] try: if where in ['prev', 'next']: diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py index 8d2523456..31e9e815f 100644 --- a/qutebrowser/browser/webkit/network/networkmanager.py +++ b/qutebrowser/browser/webkit/network/networkmanager.py @@ -21,6 +21,7 @@ import collections import html +import typing import attr from PyQt5.QtCore import (pyqtSlot, pyqtSignal, QCoreApplication, QUrl, @@ -28,6 +29,7 @@ from PyQt5.QtCore import (pyqtSlot, pyqtSignal, QCoreApplication, QUrl, from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkReply, QSslSocket from qutebrowser.config import config +from qutebrowser.mainwindow import prompt from qutebrowser.utils import (message, log, usertypes, utils, objreg, urlutils, debug) from qutebrowser.browser import shared @@ -37,7 +39,7 @@ from qutebrowser.browser.webkit.network import (webkitqutescheme, networkreply, HOSTBLOCK_ERROR_STRING = '%HOSTBLOCK%' -_proxy_auth_cache = {} +_proxy_auth_cache = {} # type: typing.Dict[ProxyId, prompt.AuthInfo] @attr.s(frozen=True) diff --git a/qutebrowser/commands/cmdutils.py b/qutebrowser/commands/cmdutils.py index f9ce91b8f..768cc430e 100644 --- a/qutebrowser/commands/cmdutils.py +++ b/qutebrowser/commands/cmdutils.py @@ -17,18 +17,15 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Contains various command utils and a global command dict. - -Module attributes: - cmd_dict: A mapping from command-strings to command objects. -""" +"""Contains various command utils and a global command dict.""" import inspect +import typing from qutebrowser.utils import qtutils, log from qutebrowser.commands import command, cmdexc -cmd_dict = {} +cmd_dict = {} # type: typing.Dict[str, command.Command] def check_overflow(arg, ctype): diff --git a/qutebrowser/config/configcache.py b/qutebrowser/config/configcache.py index dfead6664..cdba6456a 100644 --- a/qutebrowser/config/configcache.py +++ b/qutebrowser/config/configcache.py @@ -20,6 +20,8 @@ """Implementation of a basic config cache.""" +import typing + from qutebrowser.config import config @@ -36,7 +38,7 @@ class ConfigCache: """ def __init__(self) -> None: - self._cache = {} + self._cache = {} # type: typing.Dict[str, typing.Any] config.instance.changed.connect(self._on_config_changed) def _on_config_changed(self, attr: str) -> None: diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 5503ea4f3..0314805c0 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -52,6 +52,7 @@ import datetime import functools import operator import json +import typing import attr import yaml @@ -304,7 +305,7 @@ class MappingType(BaseType): MAPPING: The mapping to use. """ - MAPPING = {} + MAPPING = {} # type: typing.Dict[str, typing.Any] def __init__(self, none_ok=False, valid_values=None): super().__init__(none_ok) @@ -576,7 +577,7 @@ class FlagList(List): the valid values of the setting. """ - combinable_values = None + combinable_values = None # type: typing.Optional[typing.Iterable] _show_valtype = False