Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spyder-ide/qtpy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.4.2
Choose a base ref
...
head repository: spyder-ide/qtpy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 14 commits
  • 8 files changed
  • 4 contributors

Commits on Nov 4, 2024

  1. Back to work

    dalthviz committed Nov 4, 2024
    Copy the full SHA
    cd0b49b View commit details

Commits on Dec 7, 2024

  1. Ignore PySide 6 DeprecationWarning

    Julian Gilbey committed Dec 7, 2024
    Copy the full SHA
    a26b0c6 View commit details

Commits on Dec 12, 2024

  1. Copy the full SHA
    66a8478 View commit details
  2. Copy the full SHA
    4f0fbea View commit details
  3. Remove QMenu wrapper

    dalthviz committed Dec 12, 2024
    Copy the full SHA
    3a36157 View commit details
  4. Copy the full SHA
    27de0f4 View commit details
  5. Remove QToolBar wrapper

    dalthviz committed Dec 12, 2024
    Copy the full SHA
    6ce8edb View commit details

Commits on Dec 13, 2024

  1. Remove QAction wrapper

    dalthviz committed Dec 13, 2024
    Copy the full SHA
    6643eac View commit details
  2. Copy the full SHA
    b938c9d View commit details

Commits on Dec 16, 2024

  1. PR: Ensure QMenu and QToolBar isinstance checks succeed and rem…

    …ove unneeded wrapper classes (#507)
    ccordoba12 authored Dec 16, 2024
    Copy the full SHA
    3969d99 View commit details
  2. Copy the full SHA
    1d2a1ea View commit details

Commits on Feb 11, 2025

  1. Copy the full SHA
    5ae2bd7 View commit details
  2. Release 2.4.3

    dalthviz committed Feb 11, 2025
    Copy the full SHA
    b55c953 View commit details
  3. Back to work

    dalthviz committed Feb 11, 2025
    Copy the full SHA
    051b205 View commit details
Showing with 70 additions and 69 deletions.
  1. +7 −7 .github/workflows/ci.yml
  2. +3 −3 .github/workflows/test.sh
  3. +23 −0 CHANGELOG.md
  4. +1 −0 pytest.ini
  5. +2 −26 qtpy/QtGui.py
  6. +18 −32 qtpy/QtWidgets.py
  7. +1 −1 qtpy/__init__.py
  8. +15 −0 qtpy/tests/test_qtwidgets.py
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -130,23 +130,23 @@ jobs:
shell: bash
run: |
sudo apt update
sudo apt install libpulse-dev libegl1-mesa libopengl0 gstreamer1.0-gl
sudo apt install libpulse-dev libegl1-mesa-dev libopengl0 gstreamer1.0-gl
- uses: tlambert03/setup-qt-libs@v1
- name: Install Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ''
auto-activate-base: true
auto-update-conda: true
channels: conda-forge
conda-remove-defaults: true
channel-priority: strict
miniforge-variant: Mambaforge
use-mamba: true
miniforge-version: latest
- name: Print Conda info
shell: bash -l {0}
shell: bash -el {0}
run: |
mamba info
mamba list
conda info
conda list
- name: Test PyQt5
if: (! matrix.skip-pyqt5)
run: ./.github/workflows/test.sh pyqt5
6 changes: 3 additions & 3 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

eval "$(conda shell.bash hook)"

# Create and activate mamba environment for this test
# Create and activate conda environment for this test
BINDING=$(echo "$1" | tr '[:lower:]' '[:upper:]')
QT_VERSION_VAR=${BINDING}_QT_VERSION

@@ -27,7 +27,7 @@ if [ "$USE_CONDA" = "Yes" ]; then

fi

mamba create -y -n test-env-${BINDING} python=${PYTHON_VERSION} pytest${PYTEST_VERSION:->=6,!=7.0.0,!=7.0.1} pytest-cov>=3.0.0 pytest-qt${PYTESTQT_VERSION:-} ${QT_SPECS:-}
conda create -y -n test-env-${BINDING} python=${PYTHON_VERSION} pytest${PYTEST_VERSION:->=6,!=7.0.0,!=7.0.1} pytest-cov>=3.0.0 pytest-qt${PYTESTQT_VERSION:-} ${QT_SPECS:-}

conda activate test-env-${BINDING}

@@ -91,7 +91,7 @@ python -bb -X dev -W error -m build
echo dist/*.whl | xargs -I % python -bb -X dev -W error -W "ignore::DeprecationWarning:pip._internal.locations._distutils" -W "ignore::DeprecationWarning:distutils.command.install" -W "ignore::DeprecationWarning:pip._internal.metadata.importlib._envs" -m pip install --upgrade %

# Print environment information
mamba list
conda list

# Run tests
python -I -bb -X dev -W error -m pytest --cov qtpy --cov-config .coveragerc --cov-append
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# History of changes

## Version 2.4.3 (2025-02-11)

### Issues Closed

* [Issue 509](https://github.com/spyder-ide/qtpy/issues/509) - Release 2.4.3
* [Issue 505](https://github.com/spyder-ide/qtpy/issues/505) - Breaking change related to QMenu in 2.4.2 ([PR 507](https://github.com/spyder-ide/qtpy/pull/507) by [@dalthviz](https://github.com/dalthviz))
* [Issue 502](https://github.com/spyder-ide/qtpy/issues/502) - Hijacked PyQt types are not returned from native Qt APIs ([PR 507](https://github.com/spyder-ide/qtpy/pull/507) by [@dalthviz](https://github.com/dalthviz))
* [Issue 501](https://github.com/spyder-ide/qtpy/issues/501) - Check/fix several CI warnings ([PR 511](https://github.com/spyder-ide/qtpy/pull/511) by [@dalthviz](https://github.com/dalthviz))

In this release 4 issues were closed.

### Pull Requests Merged

* [PR 511](https://github.com/spyder-ide/qtpy/pull/511) - PR: Remove `Mambaforge` usage and update Linux setup (CI), by [@dalthviz](https://github.com/dalthviz) ([501](https://github.com/spyder-ide/qtpy/issues/501))
* [PR 507](https://github.com/spyder-ide/qtpy/pull/507) - PR: Ensure `QMenu` and `QToolBar` `isinstance` checks succeed and remove unneeded wrapper classes , by [@dalthviz](https://github.com/dalthviz) ([505](https://github.com/spyder-ide/qtpy/issues/505), [502](https://github.com/spyder-ide/qtpy/issues/502))
* [PR 506](https://github.com/spyder-ide/qtpy/pull/506) - PR: Ignore PySide6 `QSqlDatabase.exec` `DeprecationWarning`, by [@juliangilbey](https://github.com/juliangilbey)

In this release 3 pull requests were closed.


----


## Version 2.4.2 (2024-11-04)

### Issues Closed
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ addopts = --durations=10 -v -r a --color=yes --code-highlight=yes --strict-confi
empty_parameter_set_mark = fail_at_collect
filterwarnings =
error
ignore:.*QSqlDatabase\.exec\(:DeprecationWarning
log_auto_indent = True
log_level = INFO
minversion = 6.0
28 changes: 2 additions & 26 deletions qtpy/QtGui.py
Original file line number Diff line number Diff line change
@@ -227,6 +227,7 @@ def movePositionPatched(

# Follow similar approach for `QDropEvent` and child classes
QDropEvent.position = lambda self: self.posF()

if PYQT6 or PYSIDE6:
# Part of the fix for https://github.com/spyder-ide/qtpy/issues/394
for _class in (
@@ -264,27 +265,8 @@ def movePositionPatched(
QDropEvent.posF = lambda self: self.position()


# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4
if PYQT5 or PYSIDE2 or parse(_qt_version) < parse("6.4"):

class _QAction(QAction):
old_set_shortcut = QAction.setShortcut
old_set_shortcuts = QAction.setShortcuts

def setShortcut(self, shortcut):
return set_shortcut(
self,
shortcut,
old_set_shortcut=_QAction.old_set_shortcut,
)

def setShortcuts(self, shortcuts):
return set_shortcuts(
self,
shortcuts,
old_set_shortcuts=_QAction.old_set_shortcuts,
)

# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4
_action_set_shortcut = partialmethod(
set_shortcut,
old_set_shortcut=QAction.setShortcut,
@@ -295,9 +277,3 @@ def setShortcuts(self, shortcuts):
)
QAction.setShortcut = _action_set_shortcut
QAction.setShortcuts = _action_set_shortcuts
# Despite the two previous lines!
if (
QAction.setShortcut is not _action_set_shortcut
or QAction.setShortcuts is not _action_set_shortcuts
):
QAction = _QAction
50 changes: 18 additions & 32 deletions qtpy/QtWidgets.py
Original file line number Diff line number Diff line change
@@ -37,14 +37,21 @@ def __getattr__(name):
elif PYQT6:
from PyQt6 import QtWidgets
from PyQt6.QtGui import (
QAction,
QActionGroup,
QFileSystemModel,
QShortcut,
QUndoCommand,
)
from PyQt6.QtWidgets import *

from qtpy.QtGui import QAction # See spyder-ide/qtpy#461
if parse(_qt_version) < parse("6.4"):
# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4
# See spyder-ide/qtpy#461
from qtpy.QtGui import QAction
else:
from PyQt6.QtGui import QAction

from PyQt6.QtWidgets import *

# Attempt to import QOpenGLWidget, but if that fails,
# don't raise an exception until the name is explicitly accessed.
@@ -112,9 +119,15 @@ def __getattr__(name):
from PySide2.QtWidgets import *
elif PYSIDE6:
from PySide6.QtGui import QActionGroup, QShortcut, QUndoCommand
from PySide6.QtWidgets import *

from qtpy.QtGui import QAction # See spyder-ide/qtpy#461
if parse(_qt_version) < parse("6.4"):
# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4
# See spyder-ide/qtpy#461
from qtpy.QtGui import QAction
else:
from PySide6.QtGui import QAction

from PySide6.QtWidgets import *

# Attempt to import QOpenGLWidget, but if that fails,
# don't raise an exception until the name is explicitly accessed.
@@ -211,43 +224,16 @@ def __getattr__(name):
"directory",
)

# Make `addAction` compatible with Qt6 >= 6.4
if PYQT5 or PYSIDE2 or parse(_qt_version) < parse("6.4"):

class _QMenu(QMenu):
old_add_action = QMenu.addAction

def addAction(self, *args):
return add_action(
self,
*args,
old_add_action=_QMenu.old_add_action,
)

# Make `addAction` compatible with Qt6 >= 6.4
_menu_add_action = partialmethod(
add_action,
old_add_action=QMenu.addAction,
)
QMenu.addAction = _menu_add_action
# Despite the previous line!
if QMenu.addAction is not _menu_add_action:
QMenu = _QMenu

class _QToolBar(QToolBar):
old_add_action = QToolBar.addAction

def addAction(self, *args):
return add_action(
self,
*args,
old_add_action=_QToolBar.old_add_action,
)

_toolbar_add_action = partialmethod(
add_action,
old_add_action=QToolBar.addAction,
)
QToolBar.addAction = _toolbar_add_action
# Despite the previous line!
if QToolBar.addAction is not _toolbar_add_action:
QToolBar = _QToolBar
2 changes: 1 addition & 1 deletion qtpy/__init__.py
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@
from packaging.version import parse

# Version of QtPy
__version__ = "2.4.2"
__version__ = "2.5.0.dev0"


class PythonQtError(RuntimeError):
15 changes: 15 additions & 0 deletions qtpy/tests/test_qtwidgets.py
Original file line number Diff line number Diff line change
@@ -141,6 +141,14 @@ def test_QMenu_functions(qtbot):
QtWidgets.QMenu.exec_(menu.actions(), QtCore.QPoint(1, 1))


def test_QMenu_instance(qtbot):
"""Test `QtWidgets.QMenu` submenus are `QtWidgets.QMenu` instances."""
menu = QtWidgets.QMenu()
menu.addMenu("test")
submenu = menu.children()[1]
assert isinstance(submenu, QtWidgets.QMenu)


@pytest.mark.skipif(
sys.platform == "darwin" and sys.version_info[:2] == (3, 7),
reason="Stalls on macOS CI with Python 3.7",
@@ -156,6 +164,13 @@ def test_QToolBar_functions(qtbot):
)


def test_QToolBar_instance(qtbot):
"""Test `QtWidgets.QToolBar` passes `isinstance` checks."""
window = QtWidgets.QMainWindow()
new_toolbar = window.addToolBar("Toolbar title")
assert isinstance(new_toolbar, QtWidgets.QToolBar)


@pytest.mark.skipif(
PYQT5 and PYQT_VERSION.startswith("5.9"),
reason="A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.*"