Skip to content

Commit

Permalink
Ensure versions are defined before checking for outdated ones
Browse files Browse the repository at this point in the history
  • Loading branch information
CAM-Gerlach committed Dec 1, 2021
1 parent 3f1db00 commit 1c7f098
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class PythonQtWarning(Warning):
PYQT5 = True
PYQT4 = PYQT6 = PYSIDE = PYSIDE2 = PYSIDE6 = False

PYQT_VERSION = None
PYSIDE_VERSION = None
QT_VERSION = None

# Unless `FORCE_QT_API` is set, use previously imported Qt Python bindings
if not os.environ.get('FORCE_QT_API'):
if 'PyQt6' in sys.modules:
Expand All @@ -120,7 +124,6 @@ class PythonQtWarning(Warning):
try:
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
from PyQt5.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore
PYSIDE_VERSION = None

if sys.platform == 'darwin':
macos_version = parse(platform.mac_ver()[0])
Expand All @@ -145,7 +148,6 @@ class PythonQtWarning(Warning):
try:
from PyQt6.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
from PyQt6.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore
PYSIDE_VERSION = None
PYQT5 = False
PYQT6 = True
except ImportError:
Expand All @@ -157,7 +159,6 @@ class PythonQtWarning(Warning):
from PySide2 import __version__ as PYSIDE_VERSION # analysis:ignore
from PySide2.QtCore import __version__ as QT_VERSION # analysis:ignore

PYQT_VERSION = None
PYQT5 = False
PYSIDE2 = True

Expand All @@ -179,7 +180,6 @@ class PythonQtWarning(Warning):
from PySide6 import __version__ as PYSIDE_VERSION # analysis:ignore
from PySide6.QtCore import __version__ as QT_VERSION # analysis:ignore

PYQT_VERSION = None
PYQT5 = False
PYSIDE6 = True

Expand Down Expand Up @@ -215,7 +215,7 @@ def _warn_old_minor_version(name, old_version, min_version):


# Warn if using an End of Life, unsupported Qt API/binding
if parse(QT_VERSION) < parse(QT_VERSION_MIN):
if QT_VERSION and parse(QT_VERSION) < parse(QT_VERSION_MIN):
_warn_old_minor_version('Qt', QT_VERSION, QT_VERSION_MIN)
if PYQT_VERSION and parse(PYQT_VERSION) < parse(PYQT_VERSION_MIN):
_warn_old_minor_version('PyQt', PYQT_VERSION, PYQT_VERSION_MIN)
Expand Down

0 comments on commit 1c7f098

Please sign in to comment.