From 76ca4a9dd61e7179881044757d83d2bf5928819d Mon Sep 17 00:00:00 2001 From: toofar Date: Sun, 11 Sep 2022 10:27:11 +1200 Subject: mypy: handle sip conditional imports Putting ignore[type] on the second import works fine. But if we have it on both the pyqt5 and pyqt6 branch it'll complain about the other branch on each run. So pull it out to a common place we can ignore. --- qutebrowser/qt/sip.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qutebrowser/qt/sip.py b/qutebrowser/qt/sip.py index f4fe82a63..6430aa482 100644 --- a/qutebrowser/qt/sip.py +++ b/qutebrowser/qt/sip.py @@ -7,18 +7,25 @@ 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". +VENDORED_SIP=False if machinery.USE_PYSIDE6: raise machinery.Unavailable() elif machinery.USE_PYQT5: try: from PyQt5.sip import * + VENDORED_SIP=True except ImportError: - from sip import * + pass elif machinery.USE_PYQT6: try: from PyQt6.sip import * + VENDORED_SIP=True except ImportError: - from sip import * + pass + else: raise machinery.UnknownWrapper() + +if not VENDORED_SIP: + from sip import * # type: ignore[import] -- cgit v1.2.3-54-g00ecf