diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-05-19 13:15:09 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-05-19 13:15:09 +0200 |
commit | c01b47f27b46a8568096977363b38b01d138749c (patch) | |
tree | d0b47c3e9bebc757638f57a17a20e2cbc0332d15 /qutebrowser/config | |
parent | 06e49efd3d9f21058893a0c3751aa05caaf0e2f8 (diff) | |
download | qutebrowser-c01b47f27b46a8568096977363b38b01d138749c.tar.gz qutebrowser-c01b47f27b46a8568096977363b38b01d138749c.zip |
mypy: Set disallow_any_generics
See #6100
Diffstat (limited to 'qutebrowser/config')
-rw-r--r-- | qutebrowser/config/config.py | 11 | ||||
-rw-r--r-- | qutebrowser/config/configcommands.py | 4 | ||||
-rw-r--r-- | qutebrowser/config/configfiles.py | 20 | ||||
-rw-r--r-- | qutebrowser/config/websettings.py | 6 |
4 files changed, 29 insertions, 12 deletions
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 69f3ca2cc..437a54a33 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -97,7 +97,10 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name else: return False - def __call__(self, func: Callable) -> Callable: + def __call__( + self, + func: Callable[..., None], + ) -> Callable[..., None]: """Filter calls to the decorated function. Gets called when a function should be decorated. @@ -105,7 +108,9 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name Adds a filter which returns if we're not interested in the change-event and calls the wrapped function if we are. - We assume the function passed doesn't take any parameters. + We assume the function passed doesn't take any parameters. However, it + could take a "self" argument, so we can't cleary express this in the + type above. Args: func: The function to be decorated. @@ -309,7 +314,7 @@ class Config(QObject): def _init_values(self) -> None: """Populate the self._values dict.""" - self._values: Mapping = {} + self._values: Mapping[str, configutils.Values] = {} for name, opt in configdata.DATA.items(): self._values[name] = configutils.Values(opt) diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py index 2084556da..143b02fca 100644 --- a/qutebrowser/config/configcommands.py +++ b/qutebrowser/config/configcommands.py @@ -21,7 +21,7 @@ import os.path import contextlib -from typing import TYPE_CHECKING, Iterator, List, Optional +from typing import TYPE_CHECKING, Iterator, List, Optional, Any, Tuple from PyQt5.QtCore import QUrl @@ -475,7 +475,7 @@ class ConfigCommands: raise cmdutils.CommandError("{} already exists - use --force to " "overwrite!".format(filename)) - options: List = [] + options: List[Tuple[Optional[urlmatch.UrlPattern], configdata.Option, Any]] = [] if defaults: options = [(None, opt, opt.default) for _name, opt in sorted(configdata.DATA.items())] diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index a3320c5c1..6f0d0b13c 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -30,7 +30,7 @@ import configparser import contextlib import re from typing import (TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Mapping, - MutableMapping, Optional, cast) + MutableMapping, Optional, Tuple, cast) import yaml from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QSettings, qVersion @@ -302,18 +302,18 @@ class YamlConfig(QObject): self._validate_names(settings) self._build_values(settings) - def _load_settings_object(self, yaml_data: Any) -> '_SettingsType': + def _load_settings_object(self, yaml_data: Any) -> _SettingsType: """Load the settings from the settings: key.""" return self._pop_object(yaml_data, 'settings', dict) - def _load_legacy_settings_object(self, yaml_data: Any) -> '_SettingsType': + def _load_legacy_settings_object(self, yaml_data: Any) -> _SettingsType: data = self._pop_object(yaml_data, 'global', dict) settings = {} for name, value in data.items(): settings[name] = {'global': value} return settings - def _build_values(self, settings: Mapping) -> None: + def _build_values(self, settings: Mapping[str, Any]) -> None: """Build up self._values from the values in the given dict.""" errors = [] for name, yaml_values in settings.items(): @@ -740,9 +740,17 @@ class ConfigPyWriter: def __init__( self, - options: List, + options: List[ + Tuple[ + Optional[urlmatch.UrlPattern], + configdata.Option, + Any + ] + ], bindings: MutableMapping[str, Mapping[str, Optional[str]]], - *, commented: bool) -> None: + *, + commented: bool, + ) -> None: self._options = options self._bindings = bindings self._commented = commented diff --git a/qutebrowser/config/websettings.py b/qutebrowser/config/websettings.py index 896f7639c..7556d2b6d 100644 --- a/qutebrowser/config/websettings.py +++ b/qutebrowser/config/websettings.py @@ -85,7 +85,11 @@ class AttributeInfo: """Info about a settings attribute.""" - def __init__(self, *attributes: Any, converter: Callable = None) -> None: + def __init__( + self, + *attributes: Any, + converter: Callable[[Any], bool] = None, + ) -> None: self.attributes = attributes if converter is None: self.converter = lambda val: val |