summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2022-09-11 10:27:11 +1200
committertoofar <toofar@spalge.com>2022-09-11 10:27:11 +1200
commit76ca4a9dd61e7179881044757d83d2bf5928819d (patch)
tree2a2c59414ac91a11a13449939f277fd9eccfb6ed
parentc1738ca55006966e7c0ad9eacbfb58625aa88c44 (diff)
downloadqutebrowser-76ca4a9dd61e7179881044757d83d2bf5928819d.tar.gz
qutebrowser-76ca4a9dd61e7179881044757d83d2bf5928819d.zip
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.
-rw-r--r--qutebrowser/qt/sip.py11
1 files 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]