diff options
author | Florian Bruhin <me@the-compiler.org> | 2023-06-12 23:16:17 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2023-06-12 23:16:17 +0200 |
commit | 7fb2a2568e43af3f9b3164df9b908795c9a343d6 (patch) | |
tree | 8f5f5d9e6cbaba116063ed19e1ed2dae789d218f | |
parent | 89322cd9add66a6a7da8c624a916c353dbfd9021 (diff) | |
download | qutebrowser-7fb2a2568e43af3f9b3164df9b908795c9a343d6.tar.gz qutebrowser-7fb2a2568e43af3f9b3164df9b908795c9a343d6.zip |
qt: Small machinery fixups
-rw-r--r-- | qutebrowser/qt/machinery.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/qutebrowser/qt/machinery.py b/qutebrowser/qt/machinery.py index a9b88c121..2b1143887 100644 --- a/qutebrowser/qt/machinery.py +++ b/qutebrowser/qt/machinery.py @@ -10,7 +10,7 @@ import os import sys import argparse import importlib -from typing import Union +from typing import Optional # Packagers: Patch the line below to change the default wrapper for Qt 6 packages, e.g.: # sed -i 's/_DEFAULT_WRAPPER = "PyQt5"/_DEFAULT_WRAPPER = "PyQt6"/' qutebrowser/qt/machinery.py @@ -63,7 +63,7 @@ def _autoselect_wrapper() -> str: raise Error(f"No Qt wrapper found, tried {wrappers}") -def _select_wrapper(args: Union[argparse.Namespace, None]) -> str: +def _select_wrapper(args: Optional[argparse.Namespace]) -> str: """Select a Qt wrapper. - If --qt-wrapper is given, use that. @@ -119,7 +119,7 @@ IS_PYSIDE: bool _initialized = False -def init(args: Union[argparse.Namespace, None] = None) -> None: +def init(args: Optional[argparse.Namespace] = None) -> None: """Initialize Qt wrapper globals. There is two ways how this function can be called: @@ -146,12 +146,14 @@ def init(args: Union[argparse.Namespace, None] = None) -> None: else: # Explicit initialization can happen exactly once, and if it's used, there # should not be any implicit initialization (qutebrowser.qt imports) before it. - assert not _initialized, "init() already called before application init" + if _initialized: + raise Error("init() already called before application init") _initialized = True for name in WRAPPERS: # If any Qt wrapper has been imported before this, all hope is lost. - assert name not in sys.modules, f"{name} already imported" + if name in sys.modules: + raise Error(f"{name} already imported") WRAPPER = _select_wrapper(args) USE_PYQT5 = WRAPPER == "PyQt5" |