Skip to content

Commit

Permalink
Add a warning for users still running legacy Qt4-based APIs to fix #261
Browse files Browse the repository at this point in the history
  • Loading branch information
CAM-Gerlach committed Nov 17, 2021
1 parent 7ba1e0e commit 288dbe8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class PythonQtWarning(Warning):
# Names of the expected PySide2 api
PYSIDE2_API = ['pyside2']

# Names of the legacy APIs that we should warn users about
LEGACY_APIS = PYQT4_API + PYSIDE_API

# Detecting if a binding was specified by the user
binding_specified = QT_API in os.environ

Expand Down Expand Up @@ -236,4 +239,15 @@ class PythonQtWarning(Warning):
# Only available for Qt5 bindings > 5.9 on Windows
from . import QtDataVisualization as QtDatavisualization
except (ImportError, PythonQtError):
pass
pass

# Warn if using a legacy, soon to be unsupported Qt API/binding
if API in LEGACY_APIS or initial_api in LEGACY_APIS:
warnings.warn(
"A deprecated Qt4-based binding (PyQt4/PySide) was installed, "
"imported or set via the 'QT_API' environment variable. "
"To ensure your application is still supported in QtPy 2.0, "
"please make sure it doesn't depend upon, import or "
"set the 'QT_API' env var to 'pyqt', 'pyqt4' or 'pyside'.",
DeprecationWarning,
)

0 comments on commit 288dbe8

Please sign in to comment.