qt6 mypy: Lie about WebKit being available with Qt 6

185 -> 81 errors
This commit is contained in:
Florian Bruhin 2023-06-29 13:49:47 +02:00
parent 44bb9d7bad
commit 53d67e2c39
3 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -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()

View File

@ -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()