summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2022-07-30 17:06:57 +1200
committertoofar <toofar@spalge.com>2022-07-30 17:06:57 +1200
commit379257df9c5d72f0dcb3d370f5be1b53adedb394 (patch)
tree6532bcbc9b939a1768f549079d5a75b1a064570b
parentcd49f6553ea5a9bfee5423e10afc9bf65648cfa6 (diff)
downloadqutebrowser-379257df9c5d72f0dcb3d370f5be1b53adedb394.tar.gz
qutebrowser-379257df9c5d72f0dcb3d370f5be1b53adedb394.zip
handful of mypy fixes
The comment changes in qt.py might have to change once we figure out the best way to run mypy (eg with PyQt5 and 6 at the same time or one at a time? If one at a time how to properly make mypy ignore stuff like AttributeErrors?). I had to comment all the PyQt5 stuff in qt.py to get mypy to run with just PyQt6 without casting everything to Any. Presumably it's possibly to nudge mypy into type narrowing or whatever but I couldn't figure out a way to make it work. There are still lots of mypy errors, the most common ones are: * complaining about webkit not having type anymore (since I was running it with just PyQt6 installed * <somesignal> has no attribute "connect" * no override for method with "bytes" as an arg (they expect QByteArray) * complaining that a Qt module doesn't have an attribute when the attribute access is inside a 'except AttributeError' block or a 'if hasattr():' block * a few places complaining about unexpected types being passed to functions, mainly that is _EnumValueType in qutebrowser/utils/debug.py, it seems `simplewrapper` is now treated differently? Maybe we are getting real types now?
-rw-r--r--qutebrowser/browser/network/pac.py4
-rw-r--r--qutebrowser/keyinput/keyutils.py2
-rw-r--r--qutebrowser/misc/earlyinit.py2
-rw-r--r--qutebrowser/qt.py70
-rw-r--r--qutebrowser/utils/qtutils.py2
-rw-r--r--qutebrowser/utils/usertypes.py4
6 files changed, 42 insertions, 42 deletions
diff --git a/qutebrowser/browser/network/pac.py b/qutebrowser/browser/network/pac.py
index df3bd1466..68a6b12ee 100644
--- a/qutebrowser/browser/network/pac.py
+++ b/qutebrowser/browser/network/pac.py
@@ -214,8 +214,8 @@ class PACResolver:
else:
string_flags = core.QUrl.UrlFormattingOption.RemoveUserInfo # type: ignore[assignment]
if query.url().scheme() == 'https':
- string_flags |= core.QUrl.UrlFormattingOption.RemovePath # type: ignore[assignment]
- string_flags |= core.QUrl.UrlFormattingOption.RemoveQuery # type: ignore[assignment]
+ string_flags |= core.QUrl.UrlFormattingOption.RemovePath
+ string_flags |= core.QUrl.UrlFormattingOption.RemoveQuery
result = self._resolver.call([query.url().toString(string_flags),
query.peerHostName()])
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index 8d4de6035..9b137d9e2 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -67,7 +67,7 @@ try:
except ValueError:
# WORKAROUND for
# https://www.riverbankcomputing.com/pipermail/pyqt/2022-April/044607.html
- _NIL_KEY = 0
+ _NIL_KEY: core.Qt.Key = 0
_ModifierType = core.Qt.KeyboardModifier
diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py
index 9550f147f..cc9726eb3 100644
--- a/qutebrowser/misc/earlyinit.py
+++ b/qutebrowser/misc/earlyinit.py
@@ -256,7 +256,7 @@ def configure_pyqt():
from qutebrowser.qt import sip
try:
- sip.enableoverflowchecking(True)
+ sip.enableoverflowchecking(True) # type: ignore[attr-defined]
except AttributeError:
# default in PyQt6
# FIXME:qt6 solve this in qutebrowser/qt/sip.py equivalent?
diff --git a/qutebrowser/qt.py b/qutebrowser/qt.py
index 3934ced0f..ea8520278 100644
--- a/qutebrowser/qt.py
+++ b/qutebrowser/qt.py
@@ -33,7 +33,7 @@ class _Machinery:
PyQt5 = PyQt6 = False
try:
- import PyQt5 as pyqt # noqa: N813
+ import PyQt5 as pyqt # type ignore # noqa: N813
PyQt5 = True
machinery = _Machinery(
@@ -42,7 +42,7 @@ try:
PACKAGE="PyQt5",
)
except ImportError:
- import PyQt6 as pyqt # type: ignore[import, no-redef] # noqa: N813
+ import PyQt6 as pyqt # type: ignore[no-redef] # noqa: N813
PyQt6 = True
machinery = _Machinery(
@@ -57,42 +57,42 @@ try:
if PyQt5:
from PyQt5 import sip
elif PyQt6:
- from PyQt6 import sip # type: ignore[no-redef]
+ from PyQt6 import sip
except ImportError:
- import sip # type: ignore[import, no-redef]
+ import sip # type: ignore[import]
# pylint: disable=ungrouped-imports
if PyQt5:
- from PyQt5 import QtCore as core # type: ignore[no-redef]
- from PyQt5 import QtDBus as dbus # type: ignore[no-redef]
- from PyQt5 import QtGui as gui # type: ignore[no-redef]
- from PyQt5 import QtNetwork as network # type: ignore[no-redef]
- from PyQt5 import QtPrintSupport as printsupport # type: ignore[no-redef]
- from PyQt5 import QtQml as qml # type: ignore[no-redef]
- from PyQt5 import QtSql as sql # type: ignore[no-redef]
- from PyQt5 import QtTest as test # type: ignore[no-redef]
- from PyQt5 import QtWidgets as widgets # type: ignore[no-redef]
+ from PyQt5 import QtCore as core
+ from PyQt5 import QtDBus as dbus
+ from PyQt5 import QtGui as gui
+ from PyQt5 import QtNetwork as network
+ from PyQt5 import QtPrintSupport as printsupport
+ from PyQt5 import QtQml as qml
+ from PyQt5 import QtSql as sql
+ from PyQt5 import QtTest as test
+ from PyQt5 import QtWidgets as widgets
opengl = gui # for QOpenGLVersionProfile
gui.QFileSystemModel = widgets.QFileSystemModel
del widgets.QFileSystemModel
elif PyQt6:
- from PyQt6 import QtCore as core # type: ignore[no-redef]
- from PyQt6 import QtDBus as dbus # type: ignore[no-redef]
- from PyQt6 import QtGui as gui # type: ignore[no-redef]
- from PyQt6 import QtNetwork as network # type: ignore[no-redef]
- from PyQt6 import QtPrintSupport as printsupport # type: ignore[no-redef]
- from PyQt6 import QtQml as qml # type: ignore[no-redef]
- from PyQt6 import QtSql as sql # type: ignore[no-redef]
- from PyQt6 import QtTest as test # type: ignore[no-redef]
- from PyQt6 import QtWidgets as widgets # type: ignore[no-redef]
- from PyQt6 import QtOpenGL as opengl # type: ignore[no-redef]
+ from PyQt6 import QtCore as core
+ from PyQt6 import QtDBus as dbus
+ from PyQt6 import QtGui as gui
+ from PyQt6 import QtNetwork as network
+ from PyQt6 import QtPrintSupport as printsupport
+ from PyQt6 import QtQml as qml
+ from PyQt6 import QtSql as sql
+ from PyQt6 import QtTest as test
+ from PyQt6 import QtWidgets as widgets
+ from PyQt6 import QtOpenGL as opengl
try:
if os.environ.get("SKIP_WEBENGINE_IMPORT"):
raise ImportError
if PyQt5:
- from PyQt5 import QtWebEngineCore as webenginecore # type: ignore[no-redef]
- from PyQt5 import QtWebEngineWidgets as webenginewidgets # type: ignore[no-redef]
+ from PyQt5 import QtWebEngineCore as webenginecore
+ from PyQt5 import QtWebEngineWidgets as webenginewidgets
# Some stuff moved from widgets to core in Qt6
for attr in [
"QWebEngineSettings",
@@ -122,21 +122,21 @@ try:
setattr(webenginecore, attr, getattr(QtWebEngine, attr))
delattr(QtWebEngine, attr)
elif PyQt6:
- from PyQt6 import QtWebEngineCore as webenginecore # type: ignore[no-redef]
- from PyQt6 import QtWebEngineWidgets as webenginewidgets # type: ignore[no-redef]
+ from PyQt6 import QtWebEngineCore as webenginecore
+ from PyQt6 import QtWebEngineWidgets as webenginewidgets
except ImportError:
- webenginecore = None # type: ignore[assignment]
- webenginewidgets = None # type: ignore[assignment]
+ webenginecore = None
+ webenginewidgets = None
try:
if os.environ.get("SKIP_WEBKIT_IMPORT"):
raise ImportError
if PyQt5:
- from PyQt5 import QtWebKit as webkit # type: ignore[no-redef]
- from PyQt5 import QtWebKitWidgets as webkitwidgets # type: ignore[no-redef]
+ from PyQt5 import QtWebKit as webkit
+ from PyQt5 import QtWebKitWidgets as webkitwidgets
elif PyQt6:
- webkit = None # type: ignore[assignment]
- webkitwidgets = None # type: ignore[assignment]
+ webkit = None
+ webkitwidgets = None
except ImportError:
- webkit = None # type: ignore[assignment]
- webkitwidgets = None # type: ignore[assignment]
+ webkit = None
+ webkitwidgets = None
diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py
index 1de453d40..9a37c8356 100644
--- a/qutebrowser/utils/qtutils.py
+++ b/qutebrowser/utils/qtutils.py
@@ -44,7 +44,7 @@ from qutebrowser.qt import core, gui, webkit
if webkit:
- qWebKitVersion = webkit.qWebKitVersion # noqa: N816
+ qWebKitVersion = webkit.qWebKitVersion # type: ignore[unreachable] # noqa: N816
else:
qWebKitVersion = lambda: None # pylint: disable=unnecessary-lambda-assignment # type: ignore[assignment] # noqa: N816
diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py
index b2e748ac7..3cafb2cde 100644
--- a/qutebrowser/utils/usertypes.py
+++ b/qutebrowser/utils/usertypes.py
@@ -489,7 +489,7 @@ class AbstractCertificateErrorWrapper:
"""A wrapper over an SSL/certificate error."""
def __init__(self) -> None:
- self._certificate_accepted = None
+ self._certificate_accepted: Optional[bool] = None
def __str__(self) -> str:
raise NotImplementedError
@@ -512,7 +512,7 @@ class AbstractCertificateErrorWrapper:
def defer(self) -> None:
raise NotImplementedError
- def certificate_was_accepted(self) -> None:
+ def certificate_was_accepted(self) -> bool:
"""Check whether the certificate was accepted by the user."""
if not self.is_overridable():
return False