summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2023-06-29 13:49:47 +0200
committerFlorian Bruhin <me@the-compiler.org>2023-06-29 21:10:01 +0200
commit53d67e2c39c40e52019503ab85efabd2981e5835 (patch)
treece4f179cb83df89a12710958edb5084b98f7c8c5
parent44bb9d7badc57ee973a4d8517c987ca3cb82805b (diff)
downloadqutebrowser-53d67e2c39c40e52019503ab85efabd2981e5835.tar.gz
qutebrowser-53d67e2c39c40e52019503ab85efabd2981e5835.zip
qt6 mypy: Lie about WebKit being available with Qt 6
185 -> 81 errors
-rw-r--r--.mypy.ini3
-rw-r--r--qutebrowser/qt/webkit.py8
-rw-r--r--qutebrowser/qt/webkitwidgets.py9
3 files changed, 18 insertions, 2 deletions
diff --git a/.mypy.ini b/.mypy.ini
index 03b5a0b1d..e0bff335f 100644
--- a/.mypy.ini
+++ b/.mypy.ini
@@ -49,6 +49,9 @@ ignore_missing_imports = True
# https://github.com/ronaldoussoren/pyobjc/issues/417
ignore_missing_imports = True
+[mypy-qutebrowser.browser.webkit.*]
+ignore_errors = True
+
[mypy-qutebrowser.browser.browsertab]
disallow_untyped_defs = True
diff --git a/qutebrowser/qt/webkit.py b/qutebrowser/qt/webkit.py
index 17516d96c..bb37e1dc9 100644
--- a/qutebrowser/qt/webkit.py
+++ b/qutebrowser/qt/webkit.py
@@ -13,6 +13,7 @@ Any API exported from this module is based on the QtWebKit 5.212 API:
https://qtwebkit.github.io/doc/qtwebkit/qtwebkit-index.html
"""
+import typing
from qutebrowser.qt import machinery
machinery.init_implicit()
@@ -20,7 +21,12 @@ machinery.init_implicit()
if machinery.USE_PYSIDE6: # pylint: disable=no-else-raise
raise machinery.Unavailable()
-elif machinery.USE_PYQT5:
+elif machinery.USE_PYQT5 or typing.TYPE_CHECKING:
+ # If we use mypy (even on Qt 6), we pretend to have WebKit available.
+ # This avoids central API (like BrowserTab) being Any because the webkit part of
+ # the unions there is missing.
+ # This causes various issues inside browser/webkit/, but we ignore those in
+ # .mypy.ini because we don't really care much about QtWebKit anymore.
from PyQt5.QtWebKit import *
elif machinery.USE_PYQT6:
raise machinery.Unavailable()
diff --git a/qutebrowser/qt/webkitwidgets.py b/qutebrowser/qt/webkitwidgets.py
index d6e7254f6..1bd602bec 100644
--- a/qutebrowser/qt/webkitwidgets.py
+++ b/qutebrowser/qt/webkitwidgets.py
@@ -13,6 +13,8 @@ Any API exported from this module is based on the QtWebKit 5.212 API:
https://qtwebkit.github.io/doc/qtwebkit/qtwebkitwidgets-index.html
"""
+import typing
+
from qutebrowser.qt import machinery
machinery.init_implicit()
@@ -20,7 +22,12 @@ machinery.init_implicit()
if machinery.USE_PYSIDE6:
raise machinery.Unavailable()
-elif machinery.USE_PYQT5:
+elif machinery.USE_PYQT5 or typing.TYPE_CHECKING:
+ # If we use mypy (even on Qt 6), we pretend to have WebKit available.
+ # This avoids central API (like BrowserTab) being Any because the webkit part of
+ # the unions there is missing.
+ # This causes various issues inside browser/webkit/, but we ignore those in
+ # .mypy.ini because we don't really care much about QtWebKit anymore.
from PyQt5.QtWebKitWidgets import *
elif machinery.USE_PYQT6:
raise machinery.Unavailable()