From 17da075699b6ea9a78c8f34443cc2c25712c2fea Mon Sep 17 00:00:00 2001 From: dalthviz Date: Wed, 29 Sep 2021 18:06:08 +0200 Subject: [PATCH 1/8] Drop Python 2: Initial Python 2 related code removal Update RELEASE instructions too Remove py3compat module Remove sys.version based validations --- .coveragerc | 1 - .github/workflows/ci.yml | 9 +- .github/workflows/test-pyqt5.sh | 23 +-- .github/workflows/test-pyside2.sh | 2 +- RELEASE.md | 12 +- qtpy/Qt3DAnimation.py | 14 +- qtpy/Qt3DCore.py | 16 +- qtpy/Qt3DExtras.py | 16 +- qtpy/Qt3DInput.py | 16 +- qtpy/Qt3DLogic.py | 16 +- qtpy/Qt3DRender.py | 16 +- qtpy/__init__.py | 1 - qtpy/compat.py | 23 ++- qtpy/py3compat.py | 261 ------------------------- qtpy/tests/test_patch_qheaderview.py | 9 +- qtpy/tests/test_qtdatavisualization.py | 8 +- qtpy/tests/test_qtmultimedia.py | 10 - qtpy/tests/test_qtwinextras.py | 2 +- qtpy/uic.py | 5 +- setup.cfg | 2 - setup.py | 4 +- 21 files changed, 80 insertions(+), 386 deletions(-) delete mode 100644 qtpy/py3compat.py delete mode 100644 setup.cfg diff --git a/.coveragerc b/.coveragerc index 105878e9..fcc86494 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,6 +4,5 @@ omit = */tests/* # Omit other files */__init__.py - */py3compat.py */compat.py */_version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ea1a6ed..0c763d7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - PYTHON_VERSION: ['2.7', '3.6', '3.8'] + PYTHON_VERSION: ['3.6', '3.8'] USE_CONDA: ['Yes', 'No'] steps: - name: Checkout branch @@ -61,11 +61,10 @@ jobs: strategy: fail-fast: false matrix: - PYTHON_VERSION: ['2.7', '3.6', '3.8'] + PYTHON_VERSION: ['3.6', '3.8'] USE_CONDA: ['Yes', 'No'] exclude: - - PYTHON_VERSION: '2.7' - USE_CONDA: 'Yes' + - USE_CONDA: 'Yes' steps: - name: Checkout branch uses: actions/checkout@v2 @@ -95,7 +94,7 @@ jobs: strategy: fail-fast: false matrix: - PYTHON_VERSION: ['2.7', '3.6', '3.8'] + PYTHON_VERSION: ['3.6', '3.8'] USE_CONDA: ['Yes', 'No'] steps: - name: Checkout branch diff --git a/.github/workflows/test-pyqt5.sh b/.github/workflows/test-pyqt5.sh index 678a3ec7..f1be5dd4 100755 --- a/.github/workflows/test-pyqt5.sh +++ b/.github/workflows/test-pyqt5.sh @@ -7,9 +7,7 @@ conda activate test-pyqt5 # Select build with QtMultimedia if [ "$(uname)" == "Darwin" ]; then - if [ "$PYTHON_VERSION" = "2.7" ]; then - export QT_VER=5.9 - elif [ "$PYTHON_VERSION" = "3.6" ]; then + if [ "$PYTHON_VERSION" = "3.6" ]; then export QT_VER=5.12 else export QT_VER=5.* @@ -17,9 +15,7 @@ if [ "$(uname)" == "Darwin" ]; then elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - if [ "$PYTHON_VERSION" = "2.7" ]; then - export QT_VER=5.9 - elif [ "$PYTHON_VERSION" = "3.6" ]; then + if [ "$PYTHON_VERSION" = "3.6" ]; then export QT_VER=5.12 else export QT_VER=5.* @@ -27,9 +23,7 @@ elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then else - if [ "$PYTHON_VERSION" = "2.7" ]; then - exit 0 - elif [ "$PYTHON_VERSION" = "3.6" ]; then + if [ "$PYTHON_VERSION" = "3.6" ]; then export QT_VER=5.9 else export QT_VER=5.* @@ -41,14 +35,9 @@ if [ "$USE_CONDA" = "Yes" ]; then conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge -q conda install -q qt=$QT_VER pyqt=$QT_VER -c conda-forge -q else - if [ "$PYTHON_VERSION" = "2.7" ]; then - # There are no pyqt5 wheels for Python 2 - exit 0 - else - # We are getting segfaults in 5.10 - conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c anaconda -q - pip install -q pyqt5 PyQtWebEngine - fi + # We are getting segfaults in 5.10 + conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c anaconda -q + pip install -q pyqt5 PyQtWebEngine fi # Install package diff --git a/.github/workflows/test-pyside2.sh b/.github/workflows/test-pyside2.sh index f5e1c271..04b3fc58 100755 --- a/.github/workflows/test-pyside2.sh +++ b/.github/workflows/test-pyside2.sh @@ -8,7 +8,7 @@ if [ "$USE_CONDA" = "Yes" ]; then # There are no conda packages for PySide2 exit 0 elif [ "$PYTHON_VERSION" != "3.6" ] && [ "$RUNNER_OS" = "Windows" ]; then - # There is no wheel for PySide 5.12 on Windows and Python 2.7 or 3.8 + # There is no wheel for PySide 5.12 on Windows and Python 3.8 exit 0 else # Simple solution to avoid failures with the Qt3D modules diff --git a/RELEASE.md b/RELEASE.md index 834408bf..c9ca3799 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -6,23 +6,27 @@ To release a new version of qtpy on PyPI: * git clean -xfdi -* Update CHANGELOG.md +* Update CHANGELOG.md using `loghub` to generate the list of issues and PRs merged to add at the top of the file + + loghub -m vX.X.X spyder-ide/qtpy * Update `_version.py` (set release version, remove 'dev0') -* git add and git commit +* git add . && git commit -m 'Release X.X.X' * python setup.py sdist * python setup.py bdist_wheel +* twine check dist/* + * twine upload dist/* -* git tag -a vX.X.X -m 'comment' +* git tag -a vX.X.X -m 'Release X.X.X' * Update `_version.py` (add 'dev0' and increment minor) -* git add and git commit +* git add . && git commit -m 'Back to work' * git push diff --git a/qtpy/Qt3DAnimation.py b/qtpy/Qt3DAnimation.py index c6625b2d..020d9ae3 100644 --- a/qtpy/Qt3DAnimation.py +++ b/qtpy/Qt3DAnimation.py @@ -9,18 +9,14 @@ # Local imports from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION -from .py3compat import PY2 if PYQT5: from PyQt5.Qt3DAnimation import * elif PYSIDE2: - if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'): - # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 - import PySide2.Qt3DAnimation as __temp - import inspect - for __name in inspect.getmembers(__temp.Qt3DAnimation): - globals()[__name[0]] = __name[1] - else: - raise PythonQtError('A bug in Shiboken prevents this') + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 + import PySide2.Qt3DAnimation as __temp + import inspect + for __name in inspect.getmembers(__temp.Qt3DAnimation): + globals()[__name[0]] = __name[1] else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/Qt3DCore.py b/qtpy/Qt3DCore.py index 523e1ded..2ae2a9e2 100644 --- a/qtpy/Qt3DCore.py +++ b/qtpy/Qt3DCore.py @@ -8,19 +8,15 @@ """Provides Qt3DCore classes and functions.""" # Local imports -from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION -from .py3compat import PY2 +from . import PYQT5, PYSIDE2, PythonQtError if PYQT5: from PyQt5.Qt3DCore import * elif PYSIDE2: - if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'): - # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 - import PySide2.Qt3DCore as __temp - import inspect - for __name in inspect.getmembers(__temp.Qt3DCore): - globals()[__name[0]] = __name[1] - else: - raise PythonQtError('A bug in Shiboken prevents this') + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 + import PySide2.Qt3DCore as __temp + import inspect + for __name in inspect.getmembers(__temp.Qt3DCore): + globals()[__name[0]] = __name[1] else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/Qt3DExtras.py b/qtpy/Qt3DExtras.py index 4f3a9c13..5996b270 100644 --- a/qtpy/Qt3DExtras.py +++ b/qtpy/Qt3DExtras.py @@ -8,19 +8,15 @@ """Provides Qt3DExtras classes and functions.""" # Local imports -from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION -from .py3compat import PY2 +from . import PYQT5, PYSIDE2, PythonQtError if PYQT5: from PyQt5.Qt3DExtras import * elif PYSIDE2: - if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'): - # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 - import PySide2.Qt3DExtras as __temp - import inspect - for __name in inspect.getmembers(__temp.Qt3DExtras): - globals()[__name[0]] = __name[1] - else: - raise PythonQtError('A bug in Shiboken prevents this') + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 + import PySide2.Qt3DExtras as __temp + import inspect + for __name in inspect.getmembers(__temp.Qt3DExtras): + globals()[__name[0]] = __name[1] else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/Qt3DInput.py b/qtpy/Qt3DInput.py index 87b9a96a..072fc44a 100644 --- a/qtpy/Qt3DInput.py +++ b/qtpy/Qt3DInput.py @@ -8,19 +8,15 @@ """Provides Qt3DInput classes and functions.""" # Local imports -from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION -from .py3compat import PY2 +from . import PYQT5, PYSIDE2, PythonQtError if PYQT5: from PyQt5.Qt3DInput import * elif PYSIDE2: - if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'): - # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 - import PySide2.Qt3DInput as __temp - import inspect - for __name in inspect.getmembers(__temp.Qt3DInput): - globals()[__name[0]] = __name[1] - else: - raise PythonQtError('A bug in Shiboken prevents this') + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 + import PySide2.Qt3DInput as __temp + import inspect + for __name in inspect.getmembers(__temp.Qt3DInput): + globals()[__name[0]] = __name[1] else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/Qt3DLogic.py b/qtpy/Qt3DLogic.py index d17f1367..d85fdb42 100644 --- a/qtpy/Qt3DLogic.py +++ b/qtpy/Qt3DLogic.py @@ -8,19 +8,15 @@ """Provides Qt3DLogic classes and functions.""" # Local imports -from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION -from .py3compat import PY2 +from . import PYQT5, PYSIDE2, PythonQtError if PYQT5: from PyQt5.Qt3DLogic import * elif PYSIDE2: - if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'): - # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 - import PySide2.Qt3DLogic as __temp - import inspect - for __name in inspect.getmembers(__temp.Qt3DLogic): - globals()[__name[0]] = __name[1] - else: - raise PythonQtError('A bug in Shiboken prevents this') + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 + import PySide2.Qt3DLogic as __temp + import inspect + for __name in inspect.getmembers(__temp.Qt3DLogic): + globals()[__name[0]] = __name[1] else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/Qt3DRender.py b/qtpy/Qt3DRender.py index f30331ae..e42ee52c 100644 --- a/qtpy/Qt3DRender.py +++ b/qtpy/Qt3DRender.py @@ -8,19 +8,15 @@ """Provides Qt3DRender classes and functions.""" # Local imports -from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION -from .py3compat import PY2 +from . import PYQT5, PYSIDE2, PythonQtError if PYQT5: from PyQt5.Qt3DRender import * elif PYSIDE2: - if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'): - # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 - import PySide2.Qt3DRender as __temp - import inspect - for __name in inspect.getmembers(__temp.Qt3DRender): - globals()[__name[0]] = __name[1] - else: - raise PythonQtError('A bug in Shiboken prevents this') + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026 + import PySide2.Qt3DRender as __temp + import inspect + for __name in inspect.getmembers(__temp.Qt3DRender): + globals()[__name[0]] = __name[1] else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/__init__.py b/qtpy/__init__.py index fa62f8b2..7cd4b272 100644 --- a/qtpy/__init__.py +++ b/qtpy/__init__.py @@ -63,7 +63,6 @@ # Version of QtPy from ._version import __version__ -from .py3compat import PY2 class PythonQtError(RuntimeError): diff --git a/qtpy/compat.py b/qtpy/compat.py index 4e34ecb4..5526ea06 100644 --- a/qtpy/compat.py +++ b/qtpy/compat.py @@ -7,11 +7,30 @@ Compatibility functions """ -from __future__ import print_function +from collections.abc import Callable import sys from .QtWidgets import QFileDialog -from .py3compat import Callable, is_text_string, to_text_string, TEXT_TYPES + + +TEXT_TYPES = (str,) + + +def is_text_string(obj): + """Return True if `obj` is a text string, False if it is anything else, + like binary data.""" + return isinstance(obj, str) + + +def to_text_string(obj, encoding=None): + """Convert `obj` to (unicode) text string""" + if encoding is None: + return str(obj) + elif isinstance(obj, str): + # In case this function is not used properly, this could happen + return obj + else: + return str(obj, encoding) # ============================================================================= diff --git a/qtpy/py3compat.py b/qtpy/py3compat.py deleted file mode 100644 index cc4bdbf5..00000000 --- a/qtpy/py3compat.py +++ /dev/null @@ -1,261 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012-2013 Pierre Raybaut -# Licensed under the terms of the MIT License -# (see spyderlib/__init__.py for details) - -""" -spyderlib.py3compat -------------------- - -Transitional module providing compatibility functions intended to help -migrating from Python 2 to Python 3. - -This module should be fully compatible with: - * Python >=v2.6 - * Python 3 -""" - -from __future__ import print_function - -import sys -import os - -PY2 = sys.version_info[0] == 2 -PY3 = sys.version_info[0] == 3 -PY33 = PY3 and sys.version_info[1] >= 3 - - -# ============================================================================= -# Data types -# ============================================================================= -if PY2: - # Python 2 - TEXT_TYPES = (str, unicode) - INT_TYPES = (int, long) -else: - # Python 3 - TEXT_TYPES = (str,) - INT_TYPES = (int,) -NUMERIC_TYPES = tuple(list(INT_TYPES) + [float, complex]) - - -# ============================================================================= -# Renamed/Reorganized modules -# ============================================================================= -if PY2: - # Python 2 - import __builtin__ as builtins - import ConfigParser as configparser - try: - import _winreg as winreg - except ImportError: - pass - from sys import maxint as maxsize - try: - import CStringIO as io - except ImportError: - import StringIO as io - try: - import cPickle as pickle - except ImportError: - import pickle - from UserDict import DictMixin as MutableMapping - import thread as _thread - import repr as reprlib -else: - # Python 3 - import builtins - import configparser - try: - import winreg - except ImportError: - pass - from sys import maxsize - import io - import pickle - if PY33: - from collections.abc import Callable, MutableMapping - else: - from collections import Callable, MutableMapping - import _thread - import reprlib - - -# ============================================================================= -# Strings -# ============================================================================= -if PY2: - # Python 2 - import codecs - - def u(obj): - """Make unicode object""" - return codecs.unicode_escape_decode(obj)[0] -else: - # Python 3 - def u(obj): - """Return string as it is""" - return obj - - -def is_text_string(obj): - """Return True if `obj` is a text string, False if it is anything else, - like binary data (Python 3) or QString (Python 2, PyQt API #1)""" - if PY2: - # Python 2 - return isinstance(obj, basestring) - else: - # Python 3 - return isinstance(obj, str) - - -def is_binary_string(obj): - """Return True if `obj` is a binary string, False if it is anything else""" - if PY2: - # Python 2 - return isinstance(obj, str) - else: - # Python 3 - return isinstance(obj, bytes) - - -def is_string(obj): - """Return True if `obj` is a text or binary Python string object, - False if it is anything else, like a QString (Python 2, PyQt API #1)""" - return is_text_string(obj) or is_binary_string(obj) - - -def is_unicode(obj): - """Return True if `obj` is unicode""" - if PY2: - # Python 2 - return isinstance(obj, unicode) - else: - # Python 3 - return isinstance(obj, str) - - -def to_text_string(obj, encoding=None): - """Convert `obj` to (unicode) text string""" - if PY2: - # Python 2 - if encoding is None: - return unicode(obj) - else: - return unicode(obj, encoding) - else: - # Python 3 - if encoding is None: - return str(obj) - elif isinstance(obj, str): - # In case this function is not used properly, this could happen - return obj - else: - return str(obj, encoding) - - -def to_binary_string(obj, encoding=None): - """Convert `obj` to binary string (bytes in Python 3, str in Python 2)""" - if PY2: - # Python 2 - if encoding is None: - return str(obj) - else: - return obj.encode(encoding) - else: - # Python 3 - return bytes(obj, 'utf-8' if encoding is None else encoding) - - -# ============================================================================= -# Function attributes -# ============================================================================= -def get_func_code(func): - """Return function code object""" - if PY2: - # Python 2 - return func.func_code - else: - # Python 3 - return func.__code__ - - -def get_func_name(func): - """Return function name""" - if PY2: - # Python 2 - return func.func_name - else: - # Python 3 - return func.__name__ - - -def get_func_defaults(func): - """Return function default argument values""" - if PY2: - # Python 2 - return func.func_defaults - else: - # Python 3 - return func.__defaults__ - - -# ============================================================================= -# Special method attributes -# ============================================================================= -def get_meth_func(obj): - """Return method function object""" - if PY2: - # Python 2 - return obj.im_func - else: - # Python 3 - return obj.__func__ - - -def get_meth_class_inst(obj): - """Return method class instance""" - if PY2: - # Python 2 - return obj.im_self - else: - # Python 3 - return obj.__self__ - - -def get_meth_class(obj): - """Return method class""" - if PY2: - # Python 2 - return obj.im_class - else: - # Python 3 - return obj.__self__.__class__ - - -# ============================================================================= -# Misc. -# ============================================================================= -if PY2: - # Python 2 - input = raw_input - getcwd = os.getcwdu - cmp = cmp - import string - str_lower = string.lower - from itertools import izip_longest as zip_longest -else: - # Python 3 - input = input - getcwd = os.getcwd - - def cmp(a, b): - return (a > b) - (a < b) - str_lower = str.lower - from itertools import zip_longest - - -def qbytearray_to_str(qba): - """Convert QByteArray object to str in a way compatible with Python 2/3""" - return str(bytes(qba.toHex().data()).decode()) diff --git a/qtpy/tests/test_patch_qheaderview.py b/qtpy/tests/test_patch_qheaderview.py index 74df889d..ffea5528 100644 --- a/qtpy/tests/test_patch_qheaderview.py +++ b/qtpy/tests/test_patch_qheaderview.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import - -import sys - import pytest from qtpy import PYSIDE2 from qtpy.QtWidgets import QApplication @@ -10,9 +6,6 @@ from qtpy.QtCore import QAbstractListModel -PY3 = sys.version[0] == "3" - - def get_qapp(icon_path=None): qapp = QApplication.instance() if qapp is None: @@ -20,7 +13,7 @@ def get_qapp(icon_path=None): return qapp -@pytest.mark.skipif(PY3 or PYSIDE2, reason="It fails on Python 3 and PySide2") +@pytest.mark.skipif(True, reason="It fails on Python 3 and PySide2") # TODO: Check patched code to remove or see if fixable for Python 3 def test_patched_qheaderview(): """ This will test whether QHeaderView has the new methods introduced in Qt5. diff --git a/qtpy/tests/test_qtdatavisualization.py b/qtpy/tests/test_qtdatavisualization.py index 8e287da6..54c7ed8f 100644 --- a/qtpy/tests/test_qtdatavisualization.py +++ b/qtpy/tests/test_qtdatavisualization.py @@ -1,13 +1,7 @@ -from __future__ import absolute_import - -import sys - import pytest -from qtpy import PYQT5, PYSIDE2 -from qtpy.py3compat import PY3 @pytest.mark.skipif( - sys.platform != "win32" or not (PYQT5 or PYSIDE2) or PY3, + True, # TODO: Check to see future usage reason="Only available in Qt5 bindings and Python 2 on Windows") def test_qtdatavisualization(): """Test the qtpy.QtDataVisualization namespace""" diff --git a/qtpy/tests/test_qtmultimedia.py b/qtpy/tests/test_qtmultimedia.py index 1d6b11e2..53e8dbc9 100644 --- a/qtpy/tests/test_qtmultimedia.py +++ b/qtpy/tests/test_qtmultimedia.py @@ -1,13 +1,3 @@ -from __future__ import absolute_import -import os -import sys - -import pytest -from qtpy import PYSIDE6 - - -@pytest.mark.skipif(sys.version_info[0] == 3, - reason="Conda packages don't seem to include QtMultimedia") def test_qtmultimedia(): """Test the qtpy.QtMultimedia namespace""" from qtpy import QtMultimedia diff --git a/qtpy/tests/test_qtwinextras.py b/qtpy/tests/test_qtwinextras.py index 546bf298..df02d31e 100644 --- a/qtpy/tests/test_qtwinextras.py +++ b/qtpy/tests/test_qtwinextras.py @@ -7,7 +7,7 @@ from qtpy import PYSIDE2, PYSIDE6 @pytest.mark.skipif( - sys.platform != "win32" or os.environ['USE_CONDA'] == 'Yes' or PYSIDE6, + sys.platform != "win32" or os.environ.get('USE_CONDA', 'Yes') == 'Yes' or PYSIDE6, reason="Only available in Qt5 bindings > 5.9 (only available with pip in the current CI setup) and Windows platform") def test_qtwinextras(): """Test the qtpy.QtWinExtras namespace""" diff --git a/qtpy/uic.py b/qtpy/uic.py index 4e2a15d2..a67be387 100644 --- a/qtpy/uic.py +++ b/qtpy/uic.py @@ -243,10 +243,7 @@ def loadUiType(uifile, from_imports=False): """ import sys - if sys.version_info >= (3, 0): - from io import StringIO - else: - from io import BytesIO as StringIO + from io import StringIO from xml.etree.ElementTree import ElementTree from . import QtWidgets diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3c6e79cf..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/setup.py b/setup.py index 3ae3e673..7223988c 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ name='QtPy', version=version_ns['__version__'], packages=find_packages(exclude=['contrib', 'docs', 'tests*']), - python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*', + python_requires='>2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*', keywords=["qt PyQt5 PyQt6 PySide2 PySide6"], url='https://github.com/spyder-ide/qtpy', license='MIT', @@ -43,8 +43,6 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', From 79fd9867411d1bb8b932a9bd15354825fa269007 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 4 Oct 2021 10:08:18 -0500 Subject: [PATCH 2/8] Drop Python 2: Remove Python 2 mention in test comment. Simplify python_requires --- qtpy/tests/test_qtpositioning.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qtpy/tests/test_qtpositioning.py b/qtpy/tests/test_qtpositioning.py index f6b5bffa..0cf95e86 100644 --- a/qtpy/tests/test_qtpositioning.py +++ b/qtpy/tests/test_qtpositioning.py @@ -14,7 +14,7 @@ def test_qtpositioning(): assert QtPositioning.QGeoCoordinate is not None assert QtPositioning.QGeoLocation is not None assert QtPositioning.QGeoPath is not None - # CI for Python 2.7 and 3.6 uses Qt 5.9 + # CI for 3.6 uses Qt 5.9 # assert QtPositioning.QGeoPolygon is not None # New in Qt 5.10 assert QtPositioning.QGeoPositionInfo is not None assert QtPositioning.QGeoPositionInfoSource is not None diff --git a/setup.py b/setup.py index 7223988c..fcc2b606 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ name='QtPy', version=version_ns['__version__'], packages=find_packages(exclude=['contrib', 'docs', 'tests*']), - python_requires='>2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*', + python_requires='>=3.6', keywords=["qt PyQt5 PyQt6 PySide2 PySide6"], url='https://github.com/spyder-ide/qtpy', license='MIT', From 1013eb102ef52df9c526bef8901d0664be1f3f22 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 4 Oct 2021 10:33:03 -0500 Subject: [PATCH 3/8] Drop Python 2: Remove exclude entry on MacOs workflow definition --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c763d7a..358ab04a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,8 +63,6 @@ jobs: matrix: PYTHON_VERSION: ['3.6', '3.8'] USE_CONDA: ['Yes', 'No'] - exclude: - - USE_CONDA: 'Yes' steps: - name: Checkout branch uses: actions/checkout@v2 From 8cc229b538f1d85da3e329af695c08f14297bd71 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 5 Oct 2021 11:41:52 -0500 Subject: [PATCH 4/8] Drop Python 2: Update tests that where skipped in Python 3 --- qtpy/tests/test_patch_qheaderview.py | 19 ++- qtpy/tests/test_qtdatavisualization.py | 154 +++++++++++++------------ 2 files changed, 97 insertions(+), 76 deletions(-) diff --git a/qtpy/tests/test_patch_qheaderview.py b/qtpy/tests/test_patch_qheaderview.py index ffea5528..1eec41dc 100644 --- a/qtpy/tests/test_patch_qheaderview.py +++ b/qtpy/tests/test_patch_qheaderview.py @@ -1,5 +1,8 @@ +import sys + import pytest -from qtpy import PYSIDE2 + +from qtpy import PYSIDE2, QT_VERSION from qtpy.QtWidgets import QApplication from qtpy.QtWidgets import QHeaderView from qtpy.QtCore import Qt @@ -13,7 +16,12 @@ def get_qapp(icon_path=None): return qapp -@pytest.mark.skipif(True, reason="It fails on Python 3 and PySide2") # TODO: Check patched code to remove or see if fixable for Python 3 +@pytest.mark.skipif( + QT_VERSION.startswith('5.15') or + (PYSIDE2 and sys.version_info.major == 3 and sys.version_info.minor == 8 and + (sys.platform == 'darwin' or sys.platform.startswith('linux')) + ), + reason="It segfaults with Qt 5.15 and fails with PySide2, Python 3.8, on MacOS and Linux") def test_patched_qheaderview(): """ This will test whether QHeaderView has the new methods introduced in Qt5. @@ -30,6 +38,7 @@ def test_patched_qheaderview(): # setup a model and add it to a headerview qapp = get_qapp() headerview = QHeaderView(Qt.Horizontal) + # Fails here on PySide 2 and Python 3.8 due a bug: https://bugreports.qt.io/browse/PYSIDE-1140 class Model(QAbstractListModel): pass model = Model() @@ -39,7 +48,11 @@ class Model(QAbstractListModel): # test it assert isinstance(headerview.sectionsClickable(), bool) assert isinstance(headerview.sectionsMovable(), bool) - assert isinstance(headerview.sectionResizeMode(0), int) + if PYSIDE2: + assert isinstance(headerview.sectionResizeMode(0), + QHeaderView.ResizeMode) + else: + assert isinstance(headerview.sectionResizeMode(0), int) headerview.setSectionsClickable(True) assert headerview.sectionsClickable() == True diff --git a/qtpy/tests/test_qtdatavisualization.py b/qtpy/tests/test_qtdatavisualization.py index 54c7ed8f..4c9968fa 100644 --- a/qtpy/tests/test_qtdatavisualization.py +++ b/qtpy/tests/test_qtdatavisualization.py @@ -1,80 +1,88 @@ import pytest -@pytest.mark.skipif( - True, # TODO: Check to see future usage - reason="Only available in Qt5 bindings and Python 2 on Windows") +from qtpy import PYQT5, PYSIDE2 + + +@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings") def test_qtdatavisualization(): """Test the qtpy.QtDataVisualization namespace""" + # Using import skip here since with Python 3 you need to install another package + # besides the base `PyQt5` or `PySide2`. + # For example in the case of `PyQt5` you need `PyQtDataVisualization` + # QtDataVisualization - assert qtpy.QtDataVisualization.QScatter3DSeries is not None - assert qtpy.QtDataVisualization.QSurfaceDataItem is not None - assert qtpy.QtDataVisualization.QSurface3DSeries is not None - assert qtpy.QtDataVisualization.QAbstract3DInputHandler is not None - assert qtpy.QtDataVisualization.QHeightMapSurfaceDataProxy is not None - assert qtpy.QtDataVisualization.QAbstractDataProxy is not None - assert qtpy.QtDataVisualization.Q3DCamera is not None - assert qtpy.QtDataVisualization.QAbstract3DGraph is not None - assert qtpy.QtDataVisualization.QCustom3DVolume is not None - assert qtpy.QtDataVisualization.Q3DInputHandler is not None - assert qtpy.QtDataVisualization.QBarDataProxy is not None - assert qtpy.QtDataVisualization.QSurfaceDataProxy is not None - assert qtpy.QtDataVisualization.QScatterDataItem is not None - assert qtpy.QtDataVisualization.Q3DLight is not None - assert qtpy.QtDataVisualization.QScatterDataProxy is not None - assert qtpy.QtDataVisualization.QValue3DAxis is not None - assert qtpy.QtDataVisualization.Q3DBars is not None - assert qtpy.QtDataVisualization.QBarDataItem is not None - assert qtpy.QtDataVisualization.QItemModelBarDataProxy is not None - assert qtpy.QtDataVisualization.Q3DTheme is not None - assert qtpy.QtDataVisualization.QCustom3DItem is not None - assert qtpy.QtDataVisualization.QItemModelScatterDataProxy is not None - assert qtpy.QtDataVisualization.QValue3DAxisFormatter is not None - assert qtpy.QtDataVisualization.QItemModelSurfaceDataProxy is not None - assert qtpy.QtDataVisualization.Q3DScatter is not None - assert qtpy.QtDataVisualization.QTouch3DInputHandler is not None - assert qtpy.QtDataVisualization.QBar3DSeries is not None - assert qtpy.QtDataVisualization.QAbstract3DAxis is not None - assert qtpy.QtDataVisualization.Q3DScene is not None - assert qtpy.QtDataVisualization.QCategory3DAxis is not None - assert qtpy.QtDataVisualization.QAbstract3DSeries is not None - assert qtpy.QtDataVisualization.Q3DObject is not None - assert qtpy.QtDataVisualization.QCustom3DLabel is not None - assert qtpy.QtDataVisualization.Q3DSurface is not None - assert qtpy.QtDataVisualization.QLogValue3DAxisFormatter is not None + QtDataVisualization = pytest.importorskip("qtpy.QtDataVisualization") + assert QtDataVisualization.QScatter3DSeries is not None + assert QtDataVisualization.QSurfaceDataItem is not None + assert QtDataVisualization.QSurface3DSeries is not None + assert QtDataVisualization.QAbstract3DInputHandler is not None + assert QtDataVisualization.QHeightMapSurfaceDataProxy is not None + assert QtDataVisualization.QAbstractDataProxy is not None + assert QtDataVisualization.Q3DCamera is not None + assert QtDataVisualization.QAbstract3DGraph is not None + assert QtDataVisualization.QCustom3DVolume is not None + assert QtDataVisualization.Q3DInputHandler is not None + assert QtDataVisualization.QBarDataProxy is not None + assert QtDataVisualization.QSurfaceDataProxy is not None + assert QtDataVisualization.QScatterDataItem is not None + assert QtDataVisualization.Q3DLight is not None + assert QtDataVisualization.QScatterDataProxy is not None + assert QtDataVisualization.QValue3DAxis is not None + assert QtDataVisualization.Q3DBars is not None + assert QtDataVisualization.QBarDataItem is not None + assert QtDataVisualization.QItemModelBarDataProxy is not None + assert QtDataVisualization.Q3DTheme is not None + assert QtDataVisualization.QCustom3DItem is not None + assert QtDataVisualization.QItemModelScatterDataProxy is not None + assert QtDataVisualization.QValue3DAxisFormatter is not None + assert QtDataVisualization.QItemModelSurfaceDataProxy is not None + assert QtDataVisualization.Q3DScatter is not None + assert QtDataVisualization.QTouch3DInputHandler is not None + assert QtDataVisualization.QBar3DSeries is not None + assert QtDataVisualization.QAbstract3DAxis is not None + assert QtDataVisualization.Q3DScene is not None + assert QtDataVisualization.QCategory3DAxis is not None + assert QtDataVisualization.QAbstract3DSeries is not None + assert QtDataVisualization.Q3DObject is not None + assert QtDataVisualization.QCustom3DLabel is not None + assert QtDataVisualization.Q3DSurface is not None + assert QtDataVisualization.QLogValue3DAxisFormatter is not None # QtDatavisualization - assert qtpy.QtDatavisualization.QScatter3DSeries is not None - assert qtpy.QtDatavisualization.QSurfaceDataItem is not None - assert qtpy.QtDatavisualization.QSurface3DSeries is not None - assert qtpy.QtDatavisualization.QAbstract3DInputHandler is not None - assert qtpy.QtDatavisualization.QHeightMapSurfaceDataProxy is not None - assert qtpy.QtDatavisualization.QAbstractDataProxy is not None - assert qtpy.QtDatavisualization.Q3DCamera is not None - assert qtpy.QtDatavisualization.QAbstract3DGraph is not None - assert qtpy.QtDatavisualization.QCustom3DVolume is not None - assert qtpy.QtDatavisualization.Q3DInputHandler is not None - assert qtpy.QtDatavisualization.QBarDataProxy is not None - assert qtpy.QtDatavisualization.QSurfaceDataProxy is not None - assert qtpy.QtDatavisualization.QScatterDataItem is not None - assert qtpy.QtDatavisualization.Q3DLight is not None - assert qtpy.QtDatavisualization.QScatterDataProxy is not None - assert qtpy.QtDatavisualization.QValue3DAxis is not None - assert qtpy.QtDatavisualization.Q3DBars is not None - assert qtpy.QtDatavisualization.QBarDataItem is not None - assert qtpy.QtDatavisualization.QItemModelBarDataProxy is not None - assert qtpy.QtDatavisualization.Q3DTheme is not None - assert qtpy.QtDatavisualization.QCustom3DItem is not None - assert qtpy.QtDatavisualization.QItemModelScatterDataProxy is not None - assert qtpy.QtDatavisualization.QValue3DAxisFormatter is not None - assert qtpy.QtDatavisualization.QItemModelSurfaceDataProxy is not None - assert qtpy.QtDatavisualization.Q3DScatter is not None - assert qtpy.QtDatavisualization.QTouch3DInputHandler is not None - assert qtpy.QtDatavisualization.QBar3DSeries is not None - assert qtpy.QtDatavisualization.QAbstract3DAxis is not None - assert qtpy.QtDatavisualization.Q3DScene is not None - assert qtpy.QtDatavisualization.QCategory3DAxis is not None - assert qtpy.QtDatavisualization.QAbstract3DSeries is not None - assert qtpy.QtDatavisualization.Q3DObject is not None - assert qtpy.QtDatavisualization.QCustom3DLabel is not None - assert qtpy.QtDatavisualization.Q3DSurface is not None - assert qtpy.QtDatavisualization.QLogValue3DAxisFormatter is not None + QtDatavisualization = pytest.importorskip("qtpy.QtDatavisualization") + + assert QtDatavisualization.QScatter3DSeries is not None + assert QtDatavisualization.QSurfaceDataItem is not None + assert QtDatavisualization.QSurface3DSeries is not None + assert QtDatavisualization.QAbstract3DInputHandler is not None + assert QtDatavisualization.QHeightMapSurfaceDataProxy is not None + assert QtDatavisualization.QAbstractDataProxy is not None + assert QtDatavisualization.Q3DCamera is not None + assert QtDatavisualization.QAbstract3DGraph is not None + assert QtDatavisualization.QCustom3DVolume is not None + assert QtDatavisualization.Q3DInputHandler is not None + assert QtDatavisualization.QBarDataProxy is not None + assert QtDatavisualization.QSurfaceDataProxy is not None + assert QtDatavisualization.QScatterDataItem is not None + assert QtDatavisualization.Q3DLight is not None + assert QtDatavisualization.QScatterDataProxy is not None + assert QtDatavisualization.QValue3DAxis is not None + assert QtDatavisualization.Q3DBars is not None + assert QtDatavisualization.QBarDataItem is not None + assert QtDatavisualization.QItemModelBarDataProxy is not None + assert QtDatavisualization.Q3DTheme is not None + assert QtDatavisualization.QCustom3DItem is not None + assert QtDatavisualization.QItemModelScatterDataProxy is not None + assert QtDatavisualization.QValue3DAxisFormatter is not None + assert QtDatavisualization.QItemModelSurfaceDataProxy is not None + assert QtDatavisualization.Q3DScatter is not None + assert QtDatavisualization.QTouch3DInputHandler is not None + assert QtDatavisualization.QBar3DSeries is not None + assert QtDatavisualization.QAbstract3DAxis is not None + assert QtDatavisualization.Q3DScene is not None + assert QtDatavisualization.QCategory3DAxis is not None + assert QtDatavisualization.QAbstract3DSeries is not None + assert QtDatavisualization.Q3DObject is not None + assert QtDatavisualization.QCustom3DLabel is not None + assert QtDatavisualization.Q3DSurface is not None + assert QtDatavisualization.QLogValue3DAxisFormatter is not None From bc8f851e723c08a1ffe0978f9f9bd522ebfa1eec Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Mon, 11 Oct 2021 17:03:16 -0500 Subject: [PATCH 5/8] Run Pyupgrade to further clean up legacy Python <3.6 syntax --- .github/workflows/test-pyqt5.sh | 6 +++--- .github/workflows/test-pyside2.sh | 2 +- qtpy/Qt3DAnimation.py | 1 - qtpy/Qt3DCore.py | 1 - qtpy/Qt3DExtras.py | 1 - qtpy/Qt3DInput.py | 1 - qtpy/Qt3DLogic.py | 1 - qtpy/Qt3DRender.py | 1 - qtpy/QtCharts.py | 1 - qtpy/QtCore.py | 1 - qtpy/QtDataVisualization.py | 1 - qtpy/QtDesigner.py | 1 - qtpy/QtGui.py | 1 - qtpy/QtHelp.py | 1 - qtpy/QtLocation.py | 1 - qtpy/QtMultimediaWidgets.py | 1 - qtpy/QtNetwork.py | 1 - qtpy/QtOpenGL.py | 1 - qtpy/QtPositioning.py | 1 - qtpy/QtPrintSupport.py | 1 - qtpy/QtQml.py | 1 - qtpy/QtQuick.py | 1 - qtpy/QtQuickWidgets.py | 1 - qtpy/QtSerialPort.py | 1 - qtpy/QtSql.py | 1 - qtpy/QtSvg.py | 1 - qtpy/QtTest.py | 1 - qtpy/QtWebChannel.py | 1 - qtpy/QtWebEngineWidgets.py | 1 - qtpy/QtWebSockets.py | 1 - qtpy/QtWidgets.py | 1 - qtpy/QtWinExtras.py | 1 - qtpy/QtXmlPatterns.py | 1 - qtpy/__init__.py | 1 - qtpy/_patch/qheaderview.py | 1 - qtpy/compat.py | 1 - qtpy/tests/conftest.py | 6 +++--- qtpy/tests/runtests.py | 1 - qtpy/tests/test_macos_checks.py | 4 +--- qtpy/tests/test_qdesktopservice_split.py | 1 - qtpy/tests/test_qt3danimation.py | 2 -- qtpy/tests/test_qt3dcore.py | 2 -- qtpy/tests/test_qt3dextras.py | 2 -- qtpy/tests/test_qt3dinput.py | 2 -- qtpy/tests/test_qt3dlogic.py | 2 -- qtpy/tests/test_qt3drender.py | 2 -- qtpy/tests/test_qtcharts.py | 2 -- qtpy/tests/test_qtcore.py | 2 -- qtpy/tests/test_qtdesigner.py | 2 -- qtpy/tests/test_qthelp.py | 1 - qtpy/tests/test_qtlocation.py | 2 -- qtpy/tests/test_qtmultimediawidgets.py | 1 - qtpy/tests/test_qtnetwork.py | 2 -- qtpy/tests/test_qtpositioning.py | 2 -- qtpy/tests/test_qtprintsupport.py | 2 -- qtpy/tests/test_qtqml.py | 2 -- qtpy/tests/test_qtquick.py | 2 -- qtpy/tests/test_qtquickwidgets.py | 2 -- qtpy/tests/test_qtserialport.py | 2 -- qtpy/tests/test_qtsql.py | 2 -- qtpy/tests/test_qtsvg.py | 2 -- qtpy/tests/test_qttest.py | 2 -- qtpy/tests/test_qtwebchannel.py | 2 -- qtpy/tests/test_qtwebenginewidgets.py | 2 -- qtpy/tests/test_qtwebsockets.py | 2 -- qtpy/tests/test_qtwinextras.py | 2 -- qtpy/tests/test_qtxmlpatterns.py | 2 -- qtpy/tests/test_uic.py | 2 +- qtpy/uic.py | 2 +- setup.py | 4 +--- 70 files changed, 11 insertions(+), 103 deletions(-) diff --git a/.github/workflows/test-pyqt5.sh b/.github/workflows/test-pyqt5.sh index f1be5dd4..cdd68b26 100755 --- a/.github/workflows/test-pyqt5.sh +++ b/.github/workflows/test-pyqt5.sh @@ -32,11 +32,11 @@ else fi if [ "$USE_CONDA" = "Yes" ]; then - conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge -q - conda install -q qt=$QT_VER pyqt=$QT_VER -c conda-forge -q + conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge + conda install -q qt=$QT_VER pyqt=$QT_VER -c conda-forge else # We are getting segfaults in 5.10 - conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c anaconda -q + conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c anaconda pip install -q pyqt5 PyQtWebEngine fi diff --git a/.github/workflows/test-pyside2.sh b/.github/workflows/test-pyside2.sh index 04b3fc58..46198351 100755 --- a/.github/workflows/test-pyside2.sh +++ b/.github/workflows/test-pyside2.sh @@ -12,7 +12,7 @@ elif [ "$PYTHON_VERSION" != "3.6" ] && [ "$RUNNER_OS" = "Windows" ]; then exit 0 else # Simple solution to avoid failures with the Qt3D modules - conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge -q + conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge pip install -q pyside2==5.12 fi diff --git a/qtpy/Qt3DAnimation.py b/qtpy/Qt3DAnimation.py index 020d9ae3..9923d2eb 100644 --- a/qtpy/Qt3DAnimation.py +++ b/qtpy/Qt3DAnimation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/Qt3DCore.py b/qtpy/Qt3DCore.py index 2ae2a9e2..cb9cc85c 100644 --- a/qtpy/Qt3DCore.py +++ b/qtpy/Qt3DCore.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/Qt3DExtras.py b/qtpy/Qt3DExtras.py index 5996b270..86b2635a 100644 --- a/qtpy/Qt3DExtras.py +++ b/qtpy/Qt3DExtras.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/Qt3DInput.py b/qtpy/Qt3DInput.py index 072fc44a..27a4ff77 100644 --- a/qtpy/Qt3DInput.py +++ b/qtpy/Qt3DInput.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/Qt3DLogic.py b/qtpy/Qt3DLogic.py index d85fdb42..e1187da3 100644 --- a/qtpy/Qt3DLogic.py +++ b/qtpy/Qt3DLogic.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/Qt3DRender.py b/qtpy/Qt3DRender.py index e42ee52c..27610e84 100644 --- a/qtpy/Qt3DRender.py +++ b/qtpy/Qt3DRender.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtCharts.py b/qtpy/QtCharts.py index 74671230..af309b13 100644 --- a/qtpy/QtCharts.py +++ b/qtpy/QtCharts.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2019- The Spyder Development Team # diff --git a/qtpy/QtCore.py b/qtpy/QtCore.py index a6142bf9..6f75e397 100644 --- a/qtpy/QtCore.py +++ b/qtpy/QtCore.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder Development Team diff --git a/qtpy/QtDataVisualization.py b/qtpy/QtDataVisualization.py index a50fe233..a0e1dfc2 100644 --- a/qtpy/QtDataVisualization.py +++ b/qtpy/QtDataVisualization.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtDesigner.py b/qtpy/QtDesigner.py index 04576785..a906f5ab 100644 --- a/qtpy/QtDesigner.py +++ b/qtpy/QtDesigner.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # diff --git a/qtpy/QtGui.py b/qtpy/QtGui.py index 62c0ee7c..c909d1a3 100644 --- a/qtpy/QtGui.py +++ b/qtpy/QtGui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder Development Team diff --git a/qtpy/QtHelp.py b/qtpy/QtHelp.py index de06baf7..b53a40e6 100644 --- a/qtpy/QtHelp.py +++ b/qtpy/QtHelp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtLocation.py b/qtpy/QtLocation.py index 9dfe874a..7241158d 100644 --- a/qtpy/QtLocation.py +++ b/qtpy/QtLocation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtMultimediaWidgets.py b/qtpy/QtMultimediaWidgets.py index 697845d9..328e166f 100644 --- a/qtpy/QtMultimediaWidgets.py +++ b/qtpy/QtMultimediaWidgets.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtNetwork.py b/qtpy/QtNetwork.py index c1fcd588..e2507d64 100644 --- a/qtpy/QtNetwork.py +++ b/qtpy/QtNetwork.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder Development Team diff --git a/qtpy/QtOpenGL.py b/qtpy/QtOpenGL.py index aaa8cd2b..fdcb5c71 100644 --- a/qtpy/QtOpenGL.py +++ b/qtpy/QtOpenGL.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtPositioning.py b/qtpy/QtPositioning.py index 2b46d356..5535ef3f 100644 --- a/qtpy/QtPositioning.py +++ b/qtpy/QtPositioning.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright 2020 Antonio Valentino # diff --git a/qtpy/QtPrintSupport.py b/qtpy/QtPrintSupport.py index 872d8179..4e512e71 100644 --- a/qtpy/QtPrintSupport.py +++ b/qtpy/QtPrintSupport.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtQml.py b/qtpy/QtQml.py index 762ac8ae..213706e9 100644 --- a/qtpy/QtQml.py +++ b/qtpy/QtQml.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtQuick.py b/qtpy/QtQuick.py index 0a28eaa0..b0697da1 100644 --- a/qtpy/QtQuick.py +++ b/qtpy/QtQuick.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtQuickWidgets.py b/qtpy/QtQuickWidgets.py index eb7884fe..fb534cff 100644 --- a/qtpy/QtQuickWidgets.py +++ b/qtpy/QtQuickWidgets.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtSerialPort.py b/qtpy/QtSerialPort.py index 26fcae18..774005c7 100644 --- a/qtpy/QtSerialPort.py +++ b/qtpy/QtSerialPort.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2020 Marcin Stano # Copyright © 2009- The Spyder Development Team diff --git a/qtpy/QtSql.py b/qtpy/QtSql.py index 0c8dcb3b..44f02884 100644 --- a/qtpy/QtSql.py +++ b/qtpy/QtSql.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtSvg.py b/qtpy/QtSvg.py index cb99e12c..4e7733b9 100644 --- a/qtpy/QtSvg.py +++ b/qtpy/QtSvg.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtTest.py b/qtpy/QtTest.py index 83ecb694..7db1e14c 100644 --- a/qtpy/QtTest.py +++ b/qtpy/QtTest.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder Developmet Team diff --git a/qtpy/QtWebChannel.py b/qtpy/QtWebChannel.py index 789bfe80..ad4fbea3 100644 --- a/qtpy/QtWebChannel.py +++ b/qtpy/QtWebChannel.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtWebEngineWidgets.py b/qtpy/QtWebEngineWidgets.py index 3b41b09a..e246ab51 100644 --- a/qtpy/QtWebEngineWidgets.py +++ b/qtpy/QtWebEngineWidgets.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder development Team diff --git a/qtpy/QtWebSockets.py b/qtpy/QtWebSockets.py index 4b6a8204..9f5b3731 100644 --- a/qtpy/QtWebSockets.py +++ b/qtpy/QtWebSockets.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtWidgets.py b/qtpy/QtWidgets.py index d7da8ef3..912d6b7b 100644 --- a/qtpy/QtWidgets.py +++ b/qtpy/QtWidgets.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder Developmet Team diff --git a/qtpy/QtWinExtras.py b/qtpy/QtWinExtras.py index c033ff98..8b870bdf 100644 --- a/qtpy/QtWinExtras.py +++ b/qtpy/QtWinExtras.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/QtXmlPatterns.py b/qtpy/QtXmlPatterns.py index 3ab2661e..f6b22a32 100644 --- a/qtpy/QtXmlPatterns.py +++ b/qtpy/QtXmlPatterns.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # diff --git a/qtpy/__init__.py b/qtpy/__init__.py index 7cd4b272..514d23bc 100644 --- a/qtpy/__init__.py +++ b/qtpy/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2009- The Spyder Development Team # Copyright © 2014-2015 Colin Duquesnoy diff --git a/qtpy/_patch/qheaderview.py b/qtpy/_patch/qheaderview.py index b6baddbb..9dee5712 100644 --- a/qtpy/_patch/qheaderview.py +++ b/qtpy/_patch/qheaderview.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © The Spyder Development Team # diff --git a/qtpy/compat.py b/qtpy/compat.py index 5526ea06..f559971b 100644 --- a/qtpy/compat.py +++ b/qtpy/compat.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2009- The Spyder Development Team # Licensed under the terms of the MIT License diff --git a/qtpy/tests/conftest.py b/qtpy/tests/conftest.py index 740cb4d2..d89776c5 100644 --- a/qtpy/tests/conftest.py +++ b/qtpy/tests/conftest.py @@ -25,7 +25,7 @@ def pytest_report_header(config): try: from PyQt6 import Qt - versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR) + versions += f"PyQt: {Qt.PYQT_VERSION_STR} - Qt: {Qt.QT_VERSION_STR}" except ImportError: versions += 'not installed' except AttributeError: @@ -36,7 +36,7 @@ def pytest_report_header(config): try: from PyQt5 import Qt - versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR) + versions += f"PyQt: {Qt.PYQT_VERSION_STR} - Qt: {Qt.QT_VERSION_STR}" except ImportError: versions += 'not installed' except AttributeError: @@ -48,7 +48,7 @@ def pytest_report_header(config): try: import PySide2 from PySide2 import QtCore - versions += "PySide: {0} - Qt: {1}".format(PySide2.__version__, QtCore.__version__) + versions += f"PySide: {PySide2.__version__} - Qt: {QtCore.__version__}" except ImportError: versions += 'not installed' except AttributeError: diff --git a/qtpy/tests/runtests.py b/qtpy/tests/runtests.py index bbac70da..ba43b9e5 100755 --- a/qtpy/tests/runtests.py +++ b/qtpy/tests/runtests.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- # ---------------------------------------------------------------------------- # Copyright © 2015- The Spyder Development Team # diff --git a/qtpy/tests/test_macos_checks.py b/qtpy/tests/test_macos_checks.py index 01aa8091..6993b315 100644 --- a/qtpy/tests/test_macos_checks.py +++ b/qtpy/tests/test_macos_checks.py @@ -1,6 +1,4 @@ -from __future__ import absolute_import - -import mock +from unittest import mock import platform import sys diff --git a/qtpy/tests/test_qdesktopservice_split.py b/qtpy/tests/test_qdesktopservice_split.py index 59e516aa..d412e9c8 100644 --- a/qtpy/tests/test_qdesktopservice_split.py +++ b/qtpy/tests/test_qdesktopservice_split.py @@ -1,6 +1,5 @@ """Test QDesktopServices split in Qt5.""" -from __future__ import absolute_import import pytest import warnings diff --git a/qtpy/tests/test_qt3danimation.py b/qtpy/tests/test_qt3danimation.py index 650be19e..3e355cb8 100644 --- a/qtpy/tests/test_qt3danimation.py +++ b/qtpy/tests/test_qt3danimation.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qt3dcore.py b/qtpy/tests/test_qt3dcore.py index 821fbd45..e3ccac8d 100644 --- a/qtpy/tests/test_qt3dcore.py +++ b/qtpy/tests/test_qt3dcore.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qt3dextras.py b/qtpy/tests/test_qt3dextras.py index f63c7d57..4a30fcdc 100644 --- a/qtpy/tests/test_qt3dextras.py +++ b/qtpy/tests/test_qt3dextras.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qt3dinput.py b/qtpy/tests/test_qt3dinput.py index 48d73d03..3f6118b0 100644 --- a/qtpy/tests/test_qt3dinput.py +++ b/qtpy/tests/test_qt3dinput.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qt3dlogic.py b/qtpy/tests/test_qt3dlogic.py index 34f7de67..8a01c33f 100644 --- a/qtpy/tests/test_qt3dlogic.py +++ b/qtpy/tests/test_qt3dlogic.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qt3drender.py b/qtpy/tests/test_qt3drender.py index f4647682..8f8813aa 100644 --- a/qtpy/tests/test_qt3drender.py +++ b/qtpy/tests/test_qt3drender.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtcharts.py b/qtpy/tests/test_qtcharts.py index 4c72dbc3..3b3f8a14 100644 --- a/qtpy/tests/test_qtcharts.py +++ b/qtpy/tests/test_qtcharts.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYSIDE2 diff --git a/qtpy/tests/test_qtcore.py b/qtpy/tests/test_qtcore.py index 81c1e6c4..196f3de2 100644 --- a/qtpy/tests/test_qtcore.py +++ b/qtpy/tests/test_qtcore.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2, QtCore diff --git a/qtpy/tests/test_qtdesigner.py b/qtpy/tests/test_qtdesigner.py index 3497f733..4e96b563 100644 --- a/qtpy/tests/test_qtdesigner.py +++ b/qtpy/tests/test_qtdesigner.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYSIDE6, PYSIDE2 diff --git a/qtpy/tests/test_qthelp.py b/qtpy/tests/test_qthelp.py index 2b70ca75..9b78912d 100644 --- a/qtpy/tests/test_qthelp.py +++ b/qtpy/tests/test_qthelp.py @@ -1,6 +1,5 @@ """Test for QtHelp namespace.""" -from __future__ import absolute_import import pytest diff --git a/qtpy/tests/test_qtlocation.py b/qtpy/tests/test_qtlocation.py index 78bf9337..012db7bc 100644 --- a/qtpy/tests/test_qtlocation.py +++ b/qtpy/tests/test_qtlocation.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtmultimediawidgets.py b/qtpy/tests/test_qtmultimediawidgets.py index bd659e51..dee6f16d 100644 --- a/qtpy/tests/test_qtmultimediawidgets.py +++ b/qtpy/tests/test_qtmultimediawidgets.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import os import sys diff --git a/qtpy/tests/test_qtnetwork.py b/qtpy/tests/test_qtnetwork.py index d8079bdf..54b3b17a 100644 --- a/qtpy/tests/test_qtnetwork.py +++ b/qtpy/tests/test_qtnetwork.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYSIDE2, PYSIDE6, QtNetwork diff --git a/qtpy/tests/test_qtpositioning.py b/qtpy/tests/test_qtpositioning.py index 0cf95e86..080ef4c5 100644 --- a/qtpy/tests/test_qtpositioning.py +++ b/qtpy/tests/test_qtpositioning.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtprintsupport.py b/qtpy/tests/test_qtprintsupport.py index 2e8f7861..cf3b1052 100644 --- a/qtpy/tests/test_qtprintsupport.py +++ b/qtpy/tests/test_qtprintsupport.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import QtPrintSupport diff --git a/qtpy/tests/test_qtqml.py b/qtpy/tests/test_qtqml.py index a6d7ca95..f2a229b9 100644 --- a/qtpy/tests/test_qtqml.py +++ b/qtpy/tests/test_qtqml.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtquick.py b/qtpy/tests/test_qtquick.py index 257fd740..d21e2af8 100644 --- a/qtpy/tests/test_qtquick.py +++ b/qtpy/tests/test_qtquick.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtquickwidgets.py b/qtpy/tests/test_qtquickwidgets.py index 0b41a8bd..f055a308 100644 --- a/qtpy/tests/test_qtquickwidgets.py +++ b/qtpy/tests/test_qtquickwidgets.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtserialport.py b/qtpy/tests/test_qtserialport.py index 26daaf76..0d740b2e 100644 --- a/qtpy/tests/test_qtserialport.py +++ b/qtpy/tests/test_qtserialport.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5 diff --git a/qtpy/tests/test_qtsql.py b/qtpy/tests/test_qtsql.py index 1e7404ff..12e8d920 100644 --- a/qtpy/tests/test_qtsql.py +++ b/qtpy/tests/test_qtsql.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import QtSql diff --git a/qtpy/tests/test_qtsvg.py b/qtpy/tests/test_qtsvg.py index 34f57a1e..56d962b1 100644 --- a/qtpy/tests/test_qtsvg.py +++ b/qtpy/tests/test_qtsvg.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYSIDE6 diff --git a/qtpy/tests/test_qttest.py b/qtpy/tests/test_qttest.py index 5d2ab9e1..64fa0d4d 100644 --- a/qtpy/tests/test_qttest.py +++ b/qtpy/tests/test_qttest.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import QtTest diff --git a/qtpy/tests/test_qtwebchannel.py b/qtpy/tests/test_qtwebchannel.py index 2beb70c0..4f33a03b 100644 --- a/qtpy/tests/test_qtwebchannel.py +++ b/qtpy/tests/test_qtwebchannel.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtwebenginewidgets.py b/qtpy/tests/test_qtwebenginewidgets.py index 7d60048c..276f5ff0 100644 --- a/qtpy/tests/test_qtwebenginewidgets.py +++ b/qtpy/tests/test_qtwebenginewidgets.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYSIDE6 diff --git a/qtpy/tests/test_qtwebsockets.py b/qtpy/tests/test_qtwebsockets.py index 5bdcc325..420aa866 100644 --- a/qtpy/tests/test_qtwebsockets.py +++ b/qtpy/tests/test_qtwebsockets.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYQT5, PYSIDE2 diff --git a/qtpy/tests/test_qtwinextras.py b/qtpy/tests/test_qtwinextras.py index df02d31e..261a4875 100644 --- a/qtpy/tests/test_qtwinextras.py +++ b/qtpy/tests/test_qtwinextras.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import os import sys diff --git a/qtpy/tests/test_qtxmlpatterns.py b/qtpy/tests/test_qtxmlpatterns.py index 5b22d2de..4f8da789 100644 --- a/qtpy/tests/test_qtxmlpatterns.py +++ b/qtpy/tests/test_qtxmlpatterns.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import pytest from qtpy import PYSIDE2, PYSIDE6 diff --git a/qtpy/tests/test_uic.py b/qtpy/tests/test_uic.py index 516d2a0e..8479de39 100644 --- a/qtpy/tests/test_uic.py +++ b/qtpy/tests/test_uic.py @@ -75,7 +75,7 @@ def test_load_ui_type(): class Widget(ui_base_type, ui_type): def __init__(self): - super(Widget, self).__init__() + super().__init__() self.setupUi(self) ui = Widget() diff --git a/qtpy/uic.py b/qtpy/uic.py index a67be387..ba0d2416 100644 --- a/qtpy/uic.py +++ b/qtpy/uic.py @@ -254,7 +254,7 @@ def loadUiType(uifile, from_imports=False): widget_class = ui.find('widget').get('class') form_class = ui.find('class').text - with open(uifile, 'r') as fd: + with open(uifile) as fd: code_stream = StringIO() frame = {} diff --git a/setup.py b/setup.py index fcc2b606..0631220f 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,10 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """ Setup script for qtpy """ import os -import io from setuptools import setup, find_packages @@ -16,7 +14,7 @@ with open(os.path.join(HERE, 'qtpy', '_version.py')) as f: exec(f.read(), {}, version_ns) -with io.open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f: +with open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f: LONG_DESCRIPTION = f.read() setup( From 390092829b324727e6690c73d075c092f9e895bc Mon Sep 17 00:00:00 2001 From: dalthviz Date: Wed, 13 Oct 2021 11:55:50 -0500 Subject: [PATCH 6/8] Drop Python 2: Update test files after PySide6 addition --- .github/workflows/test-pyside6.sh | 3 --- qtpy/QtWebEngine.py | 1 - qtpy/tests/conftest.py | 2 +- qtpy/tests/test_patch_qheaderview.py | 6 +++--- qtpy/tests/test_qtmultimedia.py | 17 ++++++++++++++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-pyside6.sh b/.github/workflows/test-pyside6.sh index 42b3ddcb..b1251ed2 100755 --- a/.github/workflows/test-pyside6.sh +++ b/.github/workflows/test-pyside6.sh @@ -7,9 +7,6 @@ conda activate test-pyside6 if [ "$USE_CONDA" = "Yes" ]; then # There are no conda packages for PySide6 exit 0 -elif [ "$PYTHON_VERSION" == "2.7" ]; then - # There is no wheel for PySide6 on Python 2.7 - exit 0 else # Simple solution to avoid failures with the Qt3D modules conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge -q diff --git a/qtpy/QtWebEngine.py b/qtpy/QtWebEngine.py index 69f0a03c..1b913a1a 100644 --- a/qtpy/QtWebEngine.py +++ b/qtpy/QtWebEngine.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright © 2014-2015 Colin Duquesnoy # Copyright © 2009- The Spyder development Team diff --git a/qtpy/tests/conftest.py b/qtpy/tests/conftest.py index d89776c5..4cbeb8dd 100644 --- a/qtpy/tests/conftest.py +++ b/qtpy/tests/conftest.py @@ -60,7 +60,7 @@ def pytest_report_header(config): try: import PySide6 from PySide6 import QtCore - versions += "PySide: {0} - Qt: {1}".format(PySide6.__version__, QtCore.__version__) + versions += f"PySide: {PySide6.__version__} - Qt: {QtCore.__version__}" except ImportError: versions += 'not installed' except AttributeError: diff --git a/qtpy/tests/test_patch_qheaderview.py b/qtpy/tests/test_patch_qheaderview.py index 1eec41dc..37fae6ed 100644 --- a/qtpy/tests/test_patch_qheaderview.py +++ b/qtpy/tests/test_patch_qheaderview.py @@ -2,7 +2,7 @@ import pytest -from qtpy import PYSIDE2, QT_VERSION +from qtpy import PYSIDE2, PYSIDE6, QT_VERSION from qtpy.QtWidgets import QApplication from qtpy.QtWidgets import QHeaderView from qtpy.QtCore import Qt @@ -17,8 +17,8 @@ def get_qapp(icon_path=None): @pytest.mark.skipif( - QT_VERSION.startswith('5.15') or - (PYSIDE2 and sys.version_info.major == 3 and sys.version_info.minor == 8 and + QT_VERSION.startswith('5.15') or PYSIDE6 or + ((PYSIDE2) and sys.version_info.major == 3 and sys.version_info.minor == 8 and (sys.platform == 'darwin' or sys.platform.startswith('linux')) ), reason="It segfaults with Qt 5.15 and fails with PySide2, Python 3.8, on MacOS and Linux") diff --git a/qtpy/tests/test_qtmultimedia.py b/qtpy/tests/test_qtmultimedia.py index 53e8dbc9..369ca19e 100644 --- a/qtpy/tests/test_qtmultimedia.py +++ b/qtpy/tests/test_qtmultimedia.py @@ -1,9 +1,20 @@ +import sys + +import pytest + +from qtpy import PYSIDE6 + +@pytest.mark.skipif( + sys.platform.startswith('linux') and PYSIDE6, + reason="Needs to setup GStreamer on Linux") def test_qtmultimedia(): """Test the qtpy.QtMultimedia namespace""" from qtpy import QtMultimedia - assert QtMultimedia.QAbstractVideoBuffer is not None assert QtMultimedia.QAudio is not None - assert QtMultimedia.QAudioDeviceInfo is not None assert QtMultimedia.QAudioInput is not None - assert QtMultimedia.QSound is not None + + if not PYSIDE6: + assert QtMultimedia.QAbstractVideoBuffer is not None + assert QtMultimedia.QAudioDeviceInfo is not None + assert QtMultimedia.QSound is not None From 954a727bd17bfde01eca9b753134a6213b9f8342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= Date: Fri, 15 Oct 2021 12:18:48 -0500 Subject: [PATCH 7/8] Drop Python 2: Remove mock usage from test-pyside6 Co-authored-by: CAM Gerlach --- .github/workflows/test-pyside6.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pyside6.sh b/.github/workflows/test-pyside6.sh index b1251ed2..eb927888 100755 --- a/.github/workflows/test-pyside6.sh +++ b/.github/workflows/test-pyside6.sh @@ -9,7 +9,7 @@ if [ "$USE_CONDA" = "Yes" ]; then exit 0 else # Simple solution to avoid failures with the Qt3D modules - conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge -q + conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge pip install -q pyside6==6.2.0 fi From 9648f8a183ebbb5ebef5e7a8b367b8141dfbb9c2 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Fri, 15 Oct 2021 12:10:24 -0500 Subject: [PATCH 8/8] Drop Python 2: Remove dead Qt4 code from qfiledialog wrapper compat fn --- qtpy/compat.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/qtpy/compat.py b/qtpy/compat.py index f559971b..3a51c921 100644 --- a/qtpy/compat.py +++ b/qtpy/compat.py @@ -78,7 +78,7 @@ def _qfiledialog_wrapper(attr, parent=None, caption='', basedir='', filters='', selectedfilter='', options=None): if options is None: options = QFileDialog.Options(0) - + func = getattr(QFileDialog, attr) # Calling QFileDialog static method @@ -86,19 +86,10 @@ def _qfiledialog_wrapper(attr, parent=None, caption='', basedir='', # On Windows platforms: redirect standard outputs _temp1, _temp2 = sys.stdout, sys.stderr sys.stdout, sys.stderr = None, None - try: - result = func(parent, caption, basedir, - filters, selectedfilter, options) - except TypeError: - # The selectedfilter option (`initialFilter` in Qt) has only been - # introduced in Jan. 2010 for PyQt v4.7, that's why we handle here - # the TypeError exception which will be raised with PyQt v4.6 - # (see Issue 960 for more details) - result = func(parent, caption, basedir, filters, options) - finally: - if sys.platform == "win32": - # On Windows platforms: restore standard outputs - sys.stdout, sys.stderr = _temp1, _temp2 + result = func(parent, caption, basedir, filters, selectedfilter, options) + if sys.platform == "win32": + # On Windows platforms: restore standard outputs + sys.stdout, sys.stderr = _temp1, _temp2 output, selectedfilter = result