mypy: Add annotations for qutebrowser.config.configtypes

This commit is contained in:
Florian Bruhin 2018-12-05 16:48:33 +01:00
parent 403e63d6f2
commit f53fd56c3d
6 changed files with 290 additions and 192 deletions

View File

@ -98,6 +98,10 @@ disallow_incomplete_defs = True
disallow_untyped_defs = True disallow_untyped_defs = True
disallow_incomplete_defs = True disallow_incomplete_defs = True
[mypy-qutebrowser.config.configtypes]
disallow_untyped_defs = True
disallow_incomplete_defs = True
[mypy-qutebrowser.api.*] [mypy-qutebrowser.api.*]
disallow_untyped_defs = True disallow_untyped_defs = True
disallow_incomplete_defs = True disallow_incomplete_defs = True

View File

@ -76,7 +76,8 @@ class ValidationError(Error):
msg: Additional error message. msg: Additional error message.
""" """
def __init__(self, value: typing.Any, msg: str) -> None: def __init__(self, value: typing.Any,
msg: typing.Union[str, Exception]) -> None:
super().__init__("Invalid value '{}' - {}".format(value, msg)) super().__init__("Invalid value '{}' - {}".format(value, msg))
self.option = None self.option = None

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ if MYPY:
from qutebrowser.config import configdata from qutebrowser.config import configdata
class _UnsetObject: class Unset:
"""Sentinel object.""" """Sentinel object."""
@ -45,7 +45,7 @@ class _UnsetObject:
return '<UNSET>' return '<UNSET>'
UNSET = _UnsetObject() UNSET = Unset()
@attr.s @attr.s

View File

@ -1542,7 +1542,7 @@ class TestRegex:
regex.to_py('foo') regex.to_py('foo')
@pytest.mark.parametrize('flags, expected', [ @pytest.mark.parametrize('flags, expected', [
(0, 0), (None, 0),
('IGNORECASE', re.IGNORECASE), ('IGNORECASE', re.IGNORECASE),
('IGNORECASE | VERBOSE', re.IGNORECASE | re.VERBOSE), ('IGNORECASE | VERBOSE', re.IGNORECASE | re.VERBOSE),
]) ])

View File

@ -26,7 +26,7 @@ from qutebrowser.utils import urlmatch
def test_unset_object_identity(): def test_unset_object_identity():
assert configutils._UnsetObject() is not configutils._UnsetObject() assert configutils.Unset() is not configutils.Unset()
assert configutils.UNSET is configutils.UNSET assert configutils.UNSET is configutils.UNSET