mypy: check_untyped_defs for entire codebase
This commit is contained in:
parent
a592651a0f
commit
cd71cee144
25
mypy.ini
25
mypy.ini
|
|
@ -21,6 +21,7 @@ warn_unreachable = True
|
|||
|
||||
# Other strictness flags
|
||||
strict_equality = True
|
||||
check_untyped_defs = True
|
||||
|
||||
# Output
|
||||
show_error_codes = True
|
||||
|
|
@ -125,27 +126,3 @@ disallow_incomplete_defs = True
|
|||
[mypy-qutebrowser.mainwindow.statusbar.command]
|
||||
disallow_untyped_defs = True
|
||||
disallow_incomplete_defs = True
|
||||
|
||||
[mypy-qutebrowser.browser.*]
|
||||
check_untyped_defs = True
|
||||
|
||||
[mypy-qutebrowser.browser.webengine.*]
|
||||
check_untyped_defs = False
|
||||
|
||||
[mypy-qutebrowser.commands.*]
|
||||
check_untyped_defs = True
|
||||
|
||||
[mypy-qutebrowser.completion.*]
|
||||
check_untyped_defs = True
|
||||
|
||||
[mypy-qutebrowser.javascript.*]
|
||||
check_untyped_defs = True
|
||||
|
||||
[mypy-qutebrowser.mainwindow.*]
|
||||
check_untyped_defs = True
|
||||
|
||||
[mypy-qutebrowser.misc.*]
|
||||
check_untyped_defs = True
|
||||
|
||||
[mypy-qutebrowser.app]
|
||||
check_untyped_defs = True
|
||||
|
|
|
|||
|
|
@ -134,16 +134,16 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
|
|||
info: QWebEngineUrlRequestInfo &info
|
||||
"""
|
||||
if 'log-requests' in objects.debug_flags:
|
||||
resource_type = debug.qenum_key(QWebEngineUrlRequestInfo,
|
||||
info.resourceType())
|
||||
navigation_type = debug.qenum_key(QWebEngineUrlRequestInfo,
|
||||
info.navigationType())
|
||||
resource_type_str = debug.qenum_key(QWebEngineUrlRequestInfo,
|
||||
info.resourceType())
|
||||
navigation_type_str = debug.qenum_key(QWebEngineUrlRequestInfo,
|
||||
info.navigationType())
|
||||
log.webview.debug("{} {}, first-party {}, resource {}, "
|
||||
"navigation {}".format(
|
||||
bytes(info.requestMethod()).decode('ascii'),
|
||||
info.requestUrl().toDisplayString(),
|
||||
info.firstPartyUrl().toDisplayString(),
|
||||
resource_type, navigation_type))
|
||||
resource_type_str, navigation_type_str))
|
||||
|
||||
url = info.requestUrl()
|
||||
first_party = info.firstPartyUrl()
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ from qutebrowser.config.websettings import AttributeInfo as Attr
|
|||
from qutebrowser.utils import utils, standarddir, qtutils, message, log
|
||||
|
||||
# The default QWebEngineProfile
|
||||
default_profile = None # type: typing.Optional[QWebEngineProfile]
|
||||
default_profile = typing.cast(QWebEngineProfile, None)
|
||||
# The QWebEngineProfile used for private (off-the-record) windows
|
||||
private_profile = None # type: typing.Optional[QWebEngineProfile]
|
||||
# The global WebEngineSettings object
|
||||
global_settings = None
|
||||
global_settings = typing.cast('WebEngineSettings', None)
|
||||
|
||||
default_user_agent = None
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import math
|
|||
import functools
|
||||
import re
|
||||
import html as html_utils
|
||||
import typing
|
||||
|
||||
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, Qt, QPoint, QPointF, QUrl,
|
||||
QTimer, QObject)
|
||||
|
|
@ -166,7 +167,7 @@ class WebEngineSearch(browsertab.AbstractSearch):
|
|||
|
||||
def __init__(self, tab, parent=None):
|
||||
super().__init__(tab, parent)
|
||||
self._flags = QWebEnginePage.FindFlags(0)
|
||||
self._flags = QWebEnginePage.FindFlags(0) # type: ignore
|
||||
self._pending_searches = 0
|
||||
|
||||
def _find(self, text, flags, callback, caller):
|
||||
|
|
@ -216,7 +217,7 @@ class WebEngineSearch(browsertab.AbstractSearch):
|
|||
return
|
||||
|
||||
self.text = text
|
||||
self._flags = QWebEnginePage.FindFlags(0)
|
||||
self._flags = QWebEnginePage.FindFlags(0) # type: ignore
|
||||
if self._is_case_sensitive(ignore_case):
|
||||
self._flags |= QWebEnginePage.FindCaseSensitively
|
||||
if reverse:
|
||||
|
|
@ -232,7 +233,7 @@ class WebEngineSearch(browsertab.AbstractSearch):
|
|||
|
||||
def prev_result(self, *, result_cb=None):
|
||||
# The int() here makes sure we get a copy of the flags.
|
||||
flags = QWebEnginePage.FindFlags(int(self._flags))
|
||||
flags = QWebEnginePage.FindFlags(int(self._flags)) # type: ignore
|
||||
if flags & QWebEnginePage.FindBackward:
|
||||
flags &= ~QWebEnginePage.FindBackward
|
||||
else:
|
||||
|
|
@ -1138,7 +1139,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
self.backend = usertypes.Backend.QtWebEngine
|
||||
self._child_event_filter = None
|
||||
self._saved_zoom = None
|
||||
self._reload_url = None
|
||||
self._reload_url = None # type: typing.Optional[QUrl]
|
||||
self._scripts.init()
|
||||
|
||||
def _set_widget(self, widget):
|
||||
|
|
@ -1196,8 +1197,9 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
self._widget.page().toHtml(callback)
|
||||
|
||||
def run_js_async(self, code, callback=None, *, world=None):
|
||||
world_id_type = typing.Union[QWebEngineScript.ScriptWorldId, int]
|
||||
if world is None:
|
||||
world_id = QWebEngineScript.ApplicationWorld
|
||||
world_id = QWebEngineScript.ApplicationWorld # type: world_id_type
|
||||
elif isinstance(world, int):
|
||||
world_id = world
|
||||
if not 0 <= world_id <= qtutils.MAX_WORLD_ID:
|
||||
|
|
@ -1264,7 +1266,9 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
title = self.title()
|
||||
title_url = QUrl(url)
|
||||
title_url.setScheme('')
|
||||
if title == title_url.toDisplayString(QUrl.RemoveScheme).strip('/'):
|
||||
title_url_str = title_url.toDisplayString(
|
||||
QUrl.RemoveScheme) # type: ignore
|
||||
if title == title_url_str.strip('/'):
|
||||
title = ""
|
||||
|
||||
# Don't add history entry if the URL is invalid anyways
|
||||
|
|
@ -1290,7 +1294,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
authenticator.setPassword(answer.password)
|
||||
else:
|
||||
try:
|
||||
sip.assign(authenticator, QAuthenticator())
|
||||
sip.assign(authenticator, QAuthenticator()) # type: ignore
|
||||
except AttributeError:
|
||||
self._show_error_page(url, "Proxy authentication required")
|
||||
|
||||
|
|
@ -1311,7 +1315,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
if not netrc_success and answer is None:
|
||||
log.network.debug("Aborting auth")
|
||||
try:
|
||||
sip.assign(authenticator, QAuthenticator())
|
||||
sip.assign(authenticator, QAuthenticator()) # type: ignore
|
||||
except AttributeError:
|
||||
# WORKAROUND for
|
||||
# https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
|
||||
|
|
@ -1536,7 +1540,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||
|
||||
try:
|
||||
# pylint: disable=unused-import
|
||||
from PyQt5.QtWebEngineWidgets import (
|
||||
from PyQt5.QtWebEngineWidgets import ( # type: ignore
|
||||
QWebEngineClientCertificateSelection)
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -216,7 +216,8 @@ class WebEnginePage(QWebEnginePage):
|
|||
self.shutting_down],
|
||||
escape_msg=escape_msg)
|
||||
except shared.CallSuper:
|
||||
return super().javaScriptPrompt(url, js_msg, default)
|
||||
return super().javaScriptPrompt( # type: ignore
|
||||
url, js_msg, default)
|
||||
|
||||
def javaScriptAlert(self, url, js_msg):
|
||||
"""Override javaScriptAlert to use qutebrowser prompts."""
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ class Question(QObject):
|
|||
self.default = None # type: typing.Union[bool, str, None]
|
||||
self.title = None # type: typing.Optional[str]
|
||||
self.text = None # type: typing.Optional[str]
|
||||
self.url = None # type: typing.Optional[QUrl]
|
||||
self.url = None # type: typing.Optional[str]
|
||||
self.option = None # type: typing.Optional[bool]
|
||||
self.answer = None # type: typing.Union[str, bool, None]
|
||||
self.is_aborted = False
|
||||
|
|
|
|||
Loading…
Reference in New Issue