diff options
-rw-r--r-- | qutebrowser/qt.py | 136 | ||||
-rw-r--r-- | qutebrowser/qt/__init__.py | 0 | ||||
-rw-r--r-- | qutebrowser/qt/core.py | 18 | ||||
-rw-r--r-- | qutebrowser/qt/dbus.py | 16 | ||||
-rw-r--r-- | qutebrowser/qt/gui.py | 22 | ||||
-rw-r--r-- | qutebrowser/qt/machinery.py | 83 | ||||
-rw-r--r-- | qutebrowser/qt/network.py | 18 | ||||
-rw-r--r-- | qutebrowser/qt/opengl.py | 18 | ||||
-rw-r--r-- | qutebrowser/qt/printsupport.py | 16 | ||||
-rw-r--r-- | qutebrowser/qt/qml.py | 16 | ||||
-rw-r--r-- | qutebrowser/qt/sip.py | 26 | ||||
-rw-r--r-- | qutebrowser/qt/sql.py | 16 | ||||
-rw-r--r-- | qutebrowser/qt/test.py | 16 | ||||
-rw-r--r-- | qutebrowser/qt/webenginecore.py | 48 | ||||
-rw-r--r-- | qutebrowser/qt/webenginewidgets.py | 34 | ||||
-rw-r--r-- | qutebrowser/qt/webkit.py | 18 | ||||
-rw-r--r-- | qutebrowser/qt/webkitwidgets.py | 18 | ||||
-rw-r--r-- | qutebrowser/qt/widgets.py | 19 | ||||
-rw-r--r-- | scripts/dev/misc_checks.py | 2 | ||||
-rw-r--r-- | tests/conftest.py | 4 |
20 files changed, 139 insertions, 405 deletions
diff --git a/qutebrowser/qt.py b/qutebrowser/qt.py new file mode 100644 index 000000000..2774d9bac --- /dev/null +++ b/qutebrowser/qt.py @@ -0,0 +1,136 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2018-2021 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see <https://www.gnu.org/licenses/>. + +"""Wrappers around Qt/PyQt code.""" + +# pylint: disable=unused-import,import-error +import importlib +from dataclasses import dataclass + +@dataclass +class _Machinery: + IS_QT6: bool + IS_QT5: bool + PACKAGE: str + +PyQt5 = PyQt6 = False +try: + import PyQt5 as pyqt # noqa: N813 + + PyQt5 = True + machinery = _Machinery( + IS_QT6=False, + IS_QT5=True, + PACKAGE="PyQt5", + ) +except ImportError: + import PyQt6 as pyqt # type: ignore[import, no-redef] # noqa: N813 + + PyQt6 = True + machinery = _Machinery( + IS_QT6=True, + IS_QT5=False, + PACKAGE="PyQt6", + ) + +# While upstream recommends using PyQt5.sip ever since PyQt5 5.11, some distributions +# still package later versions of PyQt5 with a top-level "sip" rather than "PyQt5.sip". +try: + if PyQt5: + from PyQt5 import sip + elif PyQt6: + from PyQt6 import sip # type: ignore[no-redef] +except ImportError: + import sip # type: ignore[import, no-redef] + +# 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] + 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] + +try: + if PyQt5: + from PyQt5 import QtWebEngineCore as webenginecore # type: ignore[no-redef] + from PyQt5 import QtWebEngineWidgets as webenginewidgets # type: ignore[no-redef] + # Some stuff moved from widgets to core in Qt6 + for attr in [ + "QWebEngineSettings", + "QWebEngineProfile", + "QWebEngineDownloadItem", + "QWebEnginePage", + "QWebEngineCertificateError", + "QWebEngineScript", + "QWebEngineHistory", + "QWebEngineHistoryItem", + "QWebEngineScriptCollection", + "QWebEngineClientCertificateSelection", + "QWebEngineFullScreenRequest", + "QWebEngineContextMenuData", + ]: + setattr(webenginecore, attr, getattr(webenginewidgets, attr)) + delattr(webenginewidgets, attr) + webenginecore.QWebEngineDownloadRequest = getattr( + webenginecore, + "QWebEngineDownloadItem", + ) + from PyQt5 import QtWebEngine + for attr in [ + "PYQT_WEBENGINE_VERSION", + "PYQT_WEBENGINE_VERSION_STR", + ]: + 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] +except ImportError: + webenginecore = None # type: ignore[assignment] + webenginewidgets = None # type: ignore[assignment] + +try: + if PyQt5: + from PyQt5 import QtWebKit as webkit # type: ignore[no-redef] + from PyQt5 import QtWebKitWidgets as webkitwidgets # type: ignore[no-redef] + elif PyQt6: + webkit = None # type: ignore[assignment] + webkitwidgets = None # type: ignore[assignment] +except ImportError: + webkit = None # type: ignore[assignment] + webkitwidgets = None # type: ignore[assignment] diff --git a/qutebrowser/qt/__init__.py b/qutebrowser/qt/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/qutebrowser/qt/__init__.py +++ /dev/null diff --git a/qutebrowser/qt/core.py b/qutebrowser/qt/core.py deleted file mode 100644 index d29413c64..000000000 --- a/qutebrowser/qt/core.py +++ /dev/null @@ -1,18 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtCore import * -elif machinery.USE_PYQT6: - from PyQt6.QtCore import * -elif machinery.USE_PYSIDE2: - from PySide2.QtCore import * -elif machinery.USE_PYSIDE6: - from PySide6.QtCore import * -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/dbus.py b/qutebrowser/qt/dbus.py deleted file mode 100644 index e257ba38b..000000000 --- a/qutebrowser/qt/dbus.py +++ /dev/null @@ -1,16 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtDBus import * -elif machinery.USE_PYQT6: - from PyQt6.QtDBus import * -elif machinery.USE_PYSIDE2: - from PySide2.QtDBus import * -elif machinery.USE_PYSIDE6: - from PySide6.QtDBus import * diff --git a/qutebrowser/qt/gui.py b/qutebrowser/qt/gui.py deleted file mode 100644 index 29a962541..000000000 --- a/qutebrowser/qt/gui.py +++ /dev/null @@ -1,22 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import,unused-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtGui import * - from PyQt5.QtWidgets import QFileSystemModel - del QOpenGLVersionProfile # moved to QtOpenGL in Qt 6 -elif machinery.USE_PYQT6: - from PyQt6.QtGui import * -elif machinery.USE_PYSIDE2: - from PySide2.QtGui import * - from PySide2.QtWidgets import QFileSystemModel - del QOpenGLVersionProfile # moved to QtOpenGL in Qt 6 -elif machinery.USE_PYSIDE6: - from PySide6.QtGui import * -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/machinery.py b/qutebrowser/qt/machinery.py deleted file mode 100644 index 0a2de9259..000000000 --- a/qutebrowser/qt/machinery.py +++ /dev/null @@ -1,83 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring -# flake8: noqa - -import os -import importlib - - -_WRAPPERS = [ - "PyQt6", - "PyQt5", - # Need more work, PySide2 might not be usable at all - # "PySide6", - # "PySide2", -] - - -class Error(Exception): - pass - - -class Unavailable(Error, ImportError): - - """Raised when a module is unavailable with the given wrapper.""" - - def __init__(self) -> None: - super().__init__(f"Unavailable with {WRAPPER}") - - -class UnknownWrapper(Error): - pass - - -def _autoselect_wrapper(): - for wrapper in _WRAPPERS: - try: - importlib.import_module(wrapper) - except ImportError: - # FIXME:qt6 show/log this somewhere? - continue - return wrapper - - wrappers = ", ".join(_WRAPPERS) - raise Error(f"No Qt wrapper found, tried {wrappers}") - - -def _select_wrapper(): - env_var = "QUTE_QT_WRAPPER" - env_wrapper = os.environ.get(env_var) - if env_wrapper is None: - return _autoselect_wrapper() - - if env_wrapper not in _WRAPPERS: - raise Error(f"Unknown wrapper {env_wrapper} set via {env_var}, " - f"allowed: {', '.join(_WRAPPERS)}") - - return env_wrapper - - -WRAPPER = _select_wrapper() -USE_PYQT5 = WRAPPER == "PyQt5" -USE_PYQT6 = WRAPPER == "PyQt6" -USE_PYSIDE2 = WRAPPER == "PySide2" -USE_PYSIDE6 = WRAPPER == "PySide6" -assert USE_PYQT5 ^ USE_PYQT6 ^ USE_PYSIDE2 ^ USE_PYSIDE6 - -IS_QT5 = USE_PYQT5 or USE_PYSIDE2 -IS_QT6 = USE_PYQT6 or USE_PYSIDE6 -IS_PYQT = USE_PYQT5 or USE_PYQT6 -IS_PYSIDE = USE_PYSIDE2 or USE_PYSIDE6 -assert IS_QT5 ^ IS_QT6 -assert IS_PYQT ^ IS_PYSIDE - - -if USE_PYQT5: - PACKAGE = "PyQt5" -elif USE_PYQT6: - PACKAGE = "PyQt6" -elif USE_PYSIDE2: - PACKAGE = "PySide2" -elif USE_PYSIDE6: - PACKAGE = "PySide6" diff --git a/qutebrowser/qt/network.py b/qutebrowser/qt/network.py deleted file mode 100644 index ebb28561a..000000000 --- a/qutebrowser/qt/network.py +++ /dev/null @@ -1,18 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtNetwork import * -elif machinery.USE_PYQT6: - from PyQt6.QtNetwork import * -elif machinery.USE_PYSIDE2: - from PySide2.QtNetwork import * -elif machinery.USE_PYSIDE6: - from PySide6.QtNetwork import * -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/opengl.py b/qutebrowser/qt/opengl.py deleted file mode 100644 index 4a61fbb95..000000000 --- a/qutebrowser/qt/opengl.py +++ /dev/null @@ -1,18 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtGui import QOpenGLVersionProfile -elif machinery.USE_PYQT6: - from PyQt6.QtOpenGL import * -elif machinery.USE_PYSIDE2: - from PySide2.QtGui import QOpenGLVersionProfile -elif machinery.USE_PYSIDE6: - from PySide6.QtOpenGL import * -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/printsupport.py b/qutebrowser/qt/printsupport.py deleted file mode 100644 index b0a244280..000000000 --- a/qutebrowser/qt/printsupport.py +++ /dev/null @@ -1,16 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtPrintSupport import * -elif machinery.USE_PYQT6: - from PyQt6.QtPrintSupport import * -elif machinery.USE_PYSIDE2: - from PySide2.QtPrintSupport import * -elif machinery.USE_PYSIDE6: - from PySide6.QtPrintSupport import * diff --git a/qutebrowser/qt/qml.py b/qutebrowser/qt/qml.py deleted file mode 100644 index 471a9051a..000000000 --- a/qutebrowser/qt/qml.py +++ /dev/null @@ -1,16 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtQml import * -elif machinery.USE_PYQT6: - from PyQt6.QtQml import * -elif machinery.USE_PYSIDE2: - from PySide2.QtQml import * -elif machinery.USE_PYSIDE6: - from PySide6.QtQml import * diff --git a/qutebrowser/qt/sip.py b/qutebrowser/qt/sip.py deleted file mode 100644 index 07682f24e..000000000 --- a/qutebrowser/qt/sip.py +++ /dev/null @@ -1,26 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - -# While upstream recommends using PyQt6.sip ever since PyQt6 5.11, some distributions -# still package later versions of PyQt6 with a top-level "sip" rather than "PyQt6.sip". - -if machinery.USE_PYQT5: - try: - from PyQt5.sip import * - except ImportError: - from sip import * -elif machinery.USE_PYQT6: - try: - from PyQt6.sip import * - except ImportError: - from sip import * -elif machinery.USE_PYSIDE2: - raise machinery.Unavailable() -elif machinery.USE_PYSIDE6: - raise machinery.Unavailable() -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/sql.py b/qutebrowser/qt/sql.py deleted file mode 100644 index 50a6b9d33..000000000 --- a/qutebrowser/qt/sql.py +++ /dev/null @@ -1,16 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtSql import * -elif machinery.USE_PYQT6: - from PyQt6.QtSql import * -elif machinery.USE_PYSIDE2: - from PySide2.QtSql import * -elif machinery.USE_PYSIDE6: - from PySide6.QtSql import * diff --git a/qutebrowser/qt/test.py b/qutebrowser/qt/test.py deleted file mode 100644 index 2d13107e9..000000000 --- a/qutebrowser/qt/test.py +++ /dev/null @@ -1,16 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtTest import * -elif machinery.USE_PYQT6: - from PyQt6.QtTest import * -elif machinery.USE_PYSIDE2: - from PySide2.QtTest import * -elif machinery.USE_PYSIDE6: - from PySide6.QtTest import * diff --git a/qutebrowser/qt/webenginecore.py b/qutebrowser/qt/webenginecore.py deleted file mode 100644 index 1a685cb96..000000000 --- a/qutebrowser/qt/webenginecore.py +++ /dev/null @@ -1,48 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import,unused-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtWebEngineCore import * - from PyQt5.QtWebEngineWidgets import ( - QWebEngineSettings, - QWebEngineProfile, - QWebEngineDownloadItem as QWebEngineDownloadRequest, - QWebEnginePage, - QWebEngineCertificateError, - QWebEngineScript, - QWebEngineHistory, - QWebEngineHistoryItem, - QWebEngineScriptCollection, - QWebEngineClientCertificateSelection, - QWebEngineFullScreenRequest, - QWebEngineContextMenuData as QWebEngineContextMenuRequest, - ) - # FIXME:qt6 is there a PySide2 equivalent to those? - from PyQt5.QtWebEngine import PYQT_WEBENGINE_VERSION, PYQT_WEBENGINE_VERSION_STR -elif machinery.USE_PYQT6: - from PyQt6.QtWebEngineCore import * -elif machinery.USE_PYSIDE2: - from PySide2.QtWebEngineCore import * - from PySide2.QtWebEngineWidgets import ( - QWebEngineSettings, - QWebEngineProfile, - QWebEngineDownloadItem as QWebEngineDownloadRequest, - QWebEnginePage, - QWebEngineCertificateError, - QWebEngineScript, - QWebEngineHistory, - QWebEngineHistoryItem, - QWebEngineScriptCollection, - QWebEngineClientCertificateSelection, - QWebEngineFullScreenRequest, - QWebEngineContextMenuData as QWebEngineContextMenuRequest, - ) -elif machinery.USE_PYSIDE6: - from PySide6.QtWebEngineCore import * -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/webenginewidgets.py b/qutebrowser/qt/webenginewidgets.py deleted file mode 100644 index 27f422e45..000000000 --- a/qutebrowser/qt/webenginewidgets.py +++ /dev/null @@ -1,34 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtWebEngineWidgets import * -elif machinery.USE_PYQT6: - from PyQt6.QtWebEngineWidgets import * -elif machinery.USE_PYSIDE2: - from PySide2.QtWebEngineWidgets import * -elif machinery.USE_PYSIDE6: - from PySide6.QtWebEngineWidgets import * -else: - raise machinery.UnknownWrapper() - - -if machinery.IS_QT5: - # moved to WebEngineCore in Qt 6 - del QWebEngineSettings - del QWebEngineProfile - del QWebEngineDownloadItem - del QWebEnginePage - del QWebEngineCertificateError - del QWebEngineScript - del QWebEngineHistory - del QWebEngineHistoryItem - del QWebEngineScriptCollection - del QWebEngineClientCertificateSelection - del QWebEngineFullScreenRequest - del QWebEngineContextMenuData diff --git a/qutebrowser/qt/webkit.py b/qutebrowser/qt/webkit.py deleted file mode 100644 index 3b098933f..000000000 --- a/qutebrowser/qt/webkit.py +++ /dev/null @@ -1,18 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtWebKit import * -elif machinery.USE_PYQT6: - raise machinery.Unavailable() -elif machinery.USE_PYSIDE2: - raise machinery.Unavailable() -elif machinery.USE_PYSIDE6: - raise machinery.Unavailable() -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/webkitwidgets.py b/qutebrowser/qt/webkitwidgets.py deleted file mode 100644 index 23ea42a8f..000000000 --- a/qutebrowser/qt/webkitwidgets.py +++ /dev/null @@ -1,18 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtWebKitWidgets import * -elif machinery.USE_PYQT6: - raise machinery.Unavailable() -elif machinery.USE_PYSIDE2: - raise machinery.Unavailable() -elif machinery.USE_PYSIDE6: - raise machinery.Unavailable() -else: - raise machinery.UnknownWrapper() diff --git a/qutebrowser/qt/widgets.py b/qutebrowser/qt/widgets.py deleted file mode 100644 index 4b2cde488..000000000 --- a/qutebrowser/qt/widgets.py +++ /dev/null @@ -1,19 +0,0 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# FIXME:qt6 (lint) -# pylint: disable=missing-module-docstring,import-error,wildcard-import,unused-wildcard-import -# flake8: noqa - -from qutebrowser.qt import machinery - - -if machinery.USE_PYQT5: - from PyQt5.QtWidgets import * -elif machinery.USE_PYQT6: - from PyQt6.QtWidgets import * -elif machinery.USE_PYSIDE2: - from PySide2.QtWidgets import * -elif machinery.USE_PYSIDE6: - from PySide6.QtWidgets import * - -if machinery.IS_QT5: - del QFileSystemModel # moved to QtGui in Qt 6 diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py index 0e015e03d..da987a78b 100644 --- a/scripts/dev/misc_checks.py +++ b/scripts/dev/misc_checks.py @@ -288,7 +288,7 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]: def check_pyqt_imports(args: argparse.Namespace) -> Optional[bool]: """Check for direct PyQt imports.""" ignored = [ - pathlib.Path("qutebrowser", "qt"), + pathlib.Path("qutebrowser", "qt.py"), # FIXME:qt6 fix those too? pathlib.Path("misc", "userscripts"), pathlib.Path("scripts"), diff --git a/tests/conftest.py b/tests/conftest.py index b69f1de36..b59d0ca45 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -115,11 +115,11 @@ def _apply_platform_markers(config, item): ('qt5_only', pytest.mark.skipif, not machinery.IS_QT5, - f"Only runs on Qt 5, not {machinery.WRAPPER}"), + f"Only runs on Qt 5, not {machinery.PACKAGE}"), ('qt6_only', pytest.mark.skipif, not machinery.IS_QT6, - f"Only runs on Qt 6, not {machinery.WRAPPER}"), + f"Only runs on Qt 6, not {machinery.PACKAGE}"), ('qt5_xfail', pytest.mark.xfail, machinery.IS_QT5, "Fails on Qt 5"), ('qt6_xfail', pytest.mark.skipif, machinery.IS_QT6, "Fails on Qt 6"), ] |