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 18, 2021
1 parent 7ba1e0e commit c8fd4b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
push:
branches:
- master
- '*.x'
pull_request:
branches:
- master
- '*.x'

jobs:
linux:
Expand Down
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 c8fd4b6

Please sign in to comment.