From 83f9f69c627eaaf8509bc5467fc42f2f103e3fd1 Mon Sep 17 00:00:00 2001 From: David Kincaid Date: Tue, 11 Apr 2023 23:33:00 -0400 Subject: [PATCH 1/3] Add conditional imports for modules that are now available in Qt 6.5 --- qtpy/QtLocation.py | 13 +++++++++++-- qtpy/QtTextToSpeech.py | 7 ++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/qtpy/QtLocation.py b/qtpy/QtLocation.py index 1f7132dc..cf6de337 100644 --- a/qtpy/QtLocation.py +++ b/qtpy/QtLocation.py @@ -8,18 +8,27 @@ """Provides QtLocation classes and functions.""" from . import ( + parse, PYQT5, PYQT6, PYSIDE2, PYSIDE6, + PYQT_VERSION, + PYSIDE_VERSION, QtBindingMissingModuleError, ) if PYQT5: from PyQt5.QtLocation import * elif PYQT6: - raise QtBindingMissingModuleError(name='QtLocation') + if parse(PYQT_VERSION) >= parse('6.5'): + from PyQt6.QtLocation import * + else: + raise QtBindingMissingModuleError(name='QtLocation') elif PYSIDE2: from PySide2.QtLocation import * elif PYSIDE6: - raise QtBindingMissingModuleError(name='QtLocation') + if parse(PYSIDE_VERSION) >= parse('6.5'): + from PySide6.QtLocation import * + else: + raise QtBindingMissingModuleError(name='QtLocation') diff --git a/qtpy/QtTextToSpeech.py b/qtpy/QtTextToSpeech.py index cd978328..468772ff 100644 --- a/qtpy/QtTextToSpeech.py +++ b/qtpy/QtTextToSpeech.py @@ -7,11 +7,13 @@ """Provides QtTextToSpeech classes and functions.""" +from packaging.version import parse from . import ( PYQT5, PYQT6, PYSIDE2, PYSIDE6, + PYSIDE_VERSION, QtBindingMissingModuleError, ) @@ -22,4 +24,7 @@ elif PYSIDE2: from PySide2.QtTextToSpeech import * elif PYSIDE6: - raise QtBindingMissingModuleError(name='QtTextToSpeech') + if parse(PYSIDE_VERSION) >= parse('6.5'): + from PySide6.QtTextToSpeech import * + else: + raise QtBindingMissingModuleError(name='QtTextToSpeech') From 1dbf8c3d4bd03afa2cc899de9ab580d0fff859b2 Mon Sep 17 00:00:00 2001 From: David Kincaid Date: Tue, 11 Apr 2023 23:33:15 -0400 Subject: [PATCH 2/3] Add missing QtSerialBus module --- qtpy/QtSerialBus.py | 30 ++++++++++++++++++++++++++++++ qtpy/tests/test_qtserialbus.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 qtpy/QtSerialBus.py create mode 100644 qtpy/tests/test_qtserialbus.py diff --git a/qtpy/QtSerialBus.py b/qtpy/QtSerialBus.py new file mode 100644 index 00000000..e46774bf --- /dev/null +++ b/qtpy/QtSerialBus.py @@ -0,0 +1,30 @@ +# ----------------------------------------------------------------------------- +# Copyright © 2009- The Spyder Development Team +# +# Licensed under the terms of the MIT License +# (see LICENSE.txt for details) +# ----------------------------------------------------------------------------- + +"""Provides QtSerialBus classes and functions.""" + +from . import ( + parse, + PYQT5, + PYQT6, + PYSIDE2, + PYSIDE6, + PYSIDE_VERSION, + QtBindingMissingModuleError, +) + +if PYQT5: + from PyQt5.QtSerialBus import * +elif PYQT6: + from PyQt6.QtSerialBus import * +elif PYSIDE2: + from PySide2.QtSerialBus import * +elif PYSIDE6: + if parse(PYSIDE_VERSION) >= parse('6.5'): + from PySide6.QtSerialBus import * + else: + raise QtBindingMissingModuleError(name='QtSerialBus') diff --git a/qtpy/tests/test_qtserialbus.py b/qtpy/tests/test_qtserialbus.py new file mode 100644 index 00000000..3440df94 --- /dev/null +++ b/qtpy/tests/test_qtserialbus.py @@ -0,0 +1,28 @@ +"""Test QtSerialBus.""" + +import pytest +from qtpy import ( + parse, + PYSIDE6, + PYSIDE_VERSION, + QtBindingMissingModuleError, +) + + +@pytest.mark.skipif(not PYSIDE6 or parse(PYSIDE_VERSION) >= parse('6.5'), reason='.') +def test_qtserialbus_pyside6_below_6_5(): + with pytest.raises(QtBindingMissingModuleError) as excinfo: + from qtpy import QtSerialBus + + +@pytest.mark.skipif(not PYSIDE6 or parse(PYSIDE_VERSION) < parse('6.5'), reason='.') +def test_qtserialbus_pyside6_above_6_5(): + """Test the qtpy.QtSerialBus namespace""" + from qtpy import QtSerialBus + + assert QtSerialBus.QCanBus is not None + assert QtSerialBus.QCanBusDevice is not None + assert QtSerialBus.QCanBusDeviceInfo is not None + assert QtSerialBus.QModbusClient is not None + assert QtSerialBus.QModbusServer is not None + assert QtSerialBus.QModbusDevice is not None From f59c13089e8656ff1e16d148d4b5182f10221a60 Mon Sep 17 00:00:00 2001 From: Daelon Suzuka Date: Thu, 13 Apr 2023 01:15:41 -0700 Subject: [PATCH 3/3] Update qtpy/QtTextToSpeech.py Co-authored-by: C.A.M. Gerlach --- qtpy/QtTextToSpeech.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtpy/QtTextToSpeech.py b/qtpy/QtTextToSpeech.py index 468772ff..669941c2 100644 --- a/qtpy/QtTextToSpeech.py +++ b/qtpy/QtTextToSpeech.py @@ -8,7 +8,7 @@ """Provides QtTextToSpeech classes and functions.""" from packaging.version import parse -from . import ( +from qtpy import ( PYQT5, PYQT6, PYSIDE2,