Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add a warning for developers still running legacy Qt4-based APIs #283

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)